honglei92
V2EX  ›  Kotlin

libcore.reflect.parameterizedtypeimpl cannot be cast to Java .lang.clas 这个错误 我真是莫名其妙

  •  
  •   honglei92 · May 20, 2020 · 3453 views
    This topic created in 2184 days ago, the information mentioned may be changed or developed.

    1java 方法 public void getUploadConfig(String uploadJson, final RxResultCallback<TMResponse> callBack)

    2TMRespnse 类 是泛型类 public class TMResponse<T>

    3 在 kotlin 中使用 getUploadConfig("111", object : RxResultCallback<TMResponse<Any>>()

    就报 上面的错,object : RxResultCallback<TMResponse<Any>>() 这里应该怎么写 呢?

    1 replies    2020-05-27 23:18:33 +08:00
    KentY
        1
    KentY  
       May 27, 2020
    你是要把一个新的 instance RxResultCallback<TMResponse<Any>>() 作为参数传递给那个 get... () method 吗?
    你调用一个 fun 不用 object: type, 你要么先把 object 构建好, 传 object, 要么直接
    getUploadConfig("111", RxResultCallback<TMResponse<Any>>())
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5903 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 02:00 · PVG 10:00 · LAX 19:00 · JFK 22:00
    ♥ Do have faith in what you're doing.