Java 无法从最终类错误继承

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18138136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:39:55  来源:igfitidea点击:

Cannot inherit from final class error

javacouchbasemembase

提问by TommyT

What does this error mean .. It runs fine in Eclipse but not in intellij idea

这个错误是什么意思..它在 Eclipse 中运行良好,但在 intellij idea 中运行不正常

Exception in thread "main" java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access
mvn -U idea:idea clean compile install -DskipTests
0(URLClassLoader.java:58) at java.net.URLClassLoader.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at com.couchbase.client.ViewConnection.createConnections(ViewConnection.java:120) at com.couchbase.client.ViewConnection.<init>(ViewConnection.java:100) at com.couchbase.client.CouchbaseConnectionFactory.createViewConnection(CouchbaseConnectionFactory.java:179) at com.couchbase.client.CouchbaseClient.<init>(CouchbaseClient.java:243) at com.couchbase.client.CouchbaseClient.<init>(CouchbaseClient.java:175) at com.couchbase.App.putincbase(App.java:122) at examplesCons.TestCons.run(TestCons.java:89) at examplesCons.TestCons.main(TestCons.java:121) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

I get this error when I try to run couchbase using couchbase-client-1.1.6.jar from Intellij IDea.

当我尝试使用来自 Intellij IDea 的 couchbase-client-1.1.6.jar 运行 couchbase 时出现此错误。

采纳答案by itzhar

if you're using kotlin, add opento your class (extends RealmObject) declaration

如果您使用的是 kotlin,请添加open到您的类(扩展 RealmObject)声明中

回答by Stephen C

The message means what it says.

消息意味着它所说的。

Somewhere, somehow you have managed to create a class that extends a superclass, where the superclass has been declared as final.

不知何故,您设法创建了一个扩展超类的类,其中超类已声明为final.

The most likely cause is that you have a conflict between your build classpath and your launch classpath. In other words, you are compiling your subclass against a version of the superclass that is not final, and then running against a version that is final. The verifier is saying (correctly) that this is wrong.

最可能的原因是您的构建类路径和启动类路径之间存在冲突。换句话说,您正在针对不是 的超类版本编译子类,final然后针对final. 验证者(正确地)说这是错误的。



If it is not your build / one of your classes that is causing this, then it is some internal conflict within the CouchDB client classes that you are using. Indeed the fact that this is a VerifyErrorrather than an IncompatibleClassChangeErrorsuggests that this maybe a problem with some dynamically generated bytecodes.

如果不是您的构建/您的类之一导致了这种情况,那么这是您正在使用的 CouchDB 客户端类中的一些内部冲突。事实上,这是一个VerifyError而不是一个的事实IncompatibleClassChangeError表明这可能是一些动态生成的字节码的问题。

回答by Saurabh

I also faced this with IntelliJ Idea: 2018.3 Community Edition, However running following fixed it for me:

我也在 IntelliJ Idea: 2018.3 Community Edition 中遇到了这个问题,但是运行以下内容为我修复了它:

##代码##