我收到了CloneNotSupportedException,但是在我的代码中找不到我调用clone()的任何地方。我查看了Java Docs,除了在对象上调用clone()之外,我找不到任何抛出此异常的理由。
有没有人知道调用此异常的另一个原因?当我将对象设置为等于另一个对象时,是否调用clone()?我的课程都没有实现Cloneable。
这是我的LogCat:
08-03 13:04:02.751: E/AndroidRuntime(3223): FATAL EXCEPTION: main
08-03 13:04:02.751: E/AndroidRuntime(3223): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.eti.commander/my.eti.commander.MainMenu}: java.lang.CloneNotSupportedException: Class doesn't implement Cloneable
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.os.Looper.loop(Looper.java:130)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-03 13:04:02.751: E/AndroidRuntime(3223): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 13:04:02.751: E/AndroidRuntime(3223): at java.lang.reflect.Method.invoke(Method.java:507)
08-03 13:04:02.751: E/AndroidRuntime(3223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-03 13:04:02.751: E/AndroidRuntime(3223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-03 13:04:02.751: E/AndroidRuntime(3223): at dalvik.system.NativeStart.main(Native Method)
08-03 13:04:02.751: E/AndroidRuntime(3223): Caused by: java.lang.CloneNotSupportedException: Class doesn't implement Cloneable
08-03 13:04:02.751: E/AndroidRuntime(3223): at java.lang.Object.clone(Object.java:155)
08-03 13:04:02.751: E/AndroidRuntime(3223): at my.eti.commander.RelayAPIModel$NativeCalls.InitRelayJava(Native Method)
08-03 13:04:02.751: E/AndroidRuntime(3223): at my.eti.commander.MainMenu.initMain(MainMenu.java:241)
08-03 13:04:02.751: E/AndroidRuntime(3223): at my.eti.commander.MainMenu.onCreate(MainMenu.java:81)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-03 13:04:02.751: E/AndroidRuntime(3223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-03 13:04:02.751: E/AndroidRuntime(3223): ... 11 more
答案 0 :(得分:1)
从堆栈跟踪中我猜你的本机代码中有一些东西
my.eti.commander.RelayAPIModel$NativeCalls.InitRelayJava(Native Method)
正在尝试克隆传递给它的Java对象,并且该对象不支持Cloneable。