New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] MissingOverrideRule exception when analyzing PMD under Java 9 #1074

Closed
jsotuyod opened this Issue May 2, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@jsotuyod
Member

jsotuyod commented May 2, 2018

I'm only seeing this, and sporadically, when analyzing PMD with PMD 6.3.0 under Java 9 with a full classpath

Exception in thread "main" java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "net.sourceforge.pmd.lang.xml.ast.AbstractDomNodeProxy.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of net/sourceforge/pmd/util/ClasspathClassLoader) of the current class, net/sourceforge/pmd/lang/xml/ast/AbstractDomNodeProxy, and the class loader (instance of <bootloader>) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/UserDataHandler used in the signature
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3139)
	at java.base/java.lang.Class.getDeclaredMethods(Class.java:2266)
	at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.overriddenMethods(MissingOverrideRule.java:140)
	at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.getMethodLookup(MissingOverrideRule.java:112)
	at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.visit(MissingOverrideRule.java:52)
	at net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration.jjtAccept(ASTClassOrInterfaceDeclaration.java:55)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:56)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:83)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:232)
	at net.sourceforge.pmd.lang.java.ast.ASTTypeDeclaration.jjtAccept(ASTTypeDeclaration.java:35)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:56)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:83)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:212)
	at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.visit(MissingOverrideRule.java:46)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visitAll(AbstractJavaRule.java:39)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply(AbstractJavaRule.java:27)
	at net.sourceforge.pmd.RuleSet.apply(RuleSet.java:501)
	at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:143)
	at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:183)
	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:95)
	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:50)
	at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:78)
	at net.sourceforge.pmd.processor.MonoThreadProcessor.runAnalysis(MonoThreadProcessor.java:29)
	at net.sourceforge.pmd.processor.AbstractPMDProcessor.processFiles(AbstractPMDProcessor.java:110)
	at net.sourceforge.pmd.PMD.processFiles(PMD.java:326)
	at net.sourceforge.pmd.PMD.doPMD(PMD.java:237)
	at net.sourceforge.pmd.PMD.run(PMD.java:466)
	at net.sourceforge.pmd.cli.PMDCommandLineInterface.run(PMDCommandLineInterface.java:171)
	at net.sourceforge.pmd.PMD.main(PMD.java:436)

@oowekyala any ideas?

@jsotuyod jsotuyod added the a:bug label May 2, 2018

@jsotuyod jsotuyod added this to the 6.4.0 milestone May 2, 2018

@oowekyala

This comment has been minimized.

Member

oowekyala commented May 3, 2018

I can't reproduce that bug, what OS are you running it on? This may be an artifact of using a separate classloader for type resolution, though at this point I can only guess

@jsotuyod

This comment has been minimized.

Member

jsotuyod commented May 3, 2018

MacOS X High Sierra 10.13.4

$ uname -a
Darwin ARGM026322 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64

@jsotuyod jsotuyod modified the milestones: 6.4.0, 6.5.0 May 19, 2018

@adangel

This comment has been minimized.

Member

adangel commented May 31, 2018

I've just seen this while testing maven-pmd-plugin 3.10.0 against PMD.
I was using java10: java version "10.0.1" 2018-04-17

The problem appears while analyzing pmd-xml module.

[WARNING] Error during type resolution due to: java.lang.LinkageError: loader constraint violation in interface itable initialization for class net/sourceforge/pmd/lang/xml/ast/AbstractDomNodeProxy: when selecting method "org.w3c.dom.Node.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of <bootloader>) for super interface org/w3c/dom/Node, and the class loader (instance of net/sourceforge/pmd/util/ClasspathClassLoader) of the selected method's type, net/sourceforge/pmd/lang/xml/ast/AbstractDomNodeProxy have different Class objects for the type org/w3c/dom/UserDataHandler used in the signature

It seems to be just a warning, e.g. no processing error.

It happens with the current build on master, too (using the old maven-pmd-plugin with PMD 6.4.0).

@adangel

This comment has been minimized.

Member

adangel commented May 31, 2018

Hm... since MissingOverride rule is not active yet in dogfood, it must me something else....

@adangel

This comment has been minimized.

Member

adangel commented Jun 16, 2018

New occurrence: If you execute only the pmd-xml module (e.g. ./mvnw clean install -rf :pmd-xml), maven-pmd-plugin 3.10.0 now fails.... Note: I've now enabled the MissingOverride rule...

Stacktrace:

Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/UserDataHandler"
    at java.lang.Class.getDeclaredMethods0 (Native Method)
    at java.lang.Class.privateGetDeclaredMethods (Class.java:3119)
    at java.lang.Class.getDeclaredMethods (Class.java:2268)
    at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.overriddenMethodsRec (MissingOverrideRule.java:154)
    at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.overriddenMethodsRec (MissingOverrideRule.java:190)
    at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.overriddenMethods (MissingOverrideRule.java:140)
    at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.getMethodLookup (MissingOverrideRule.java:112)
    at net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule.visit (MissingOverrideRule.java:52)
    at net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration.jjtAccept (ASTClassOrInterfaceDeclaration.java:55)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept (AbstractJavaNode.java:56)
...

Ok, no, it doesn't matter, whether you build everything or just pmd-xml....

@adangel

This comment has been minimized.

Member

adangel commented Jun 16, 2018

The problem is, that the class/interface org.w3c.dom.UserDataHandler is available on two libraries - it is a standard jdk, available through the bootloader, and it is part of jaxen-1.1.6.jar ... it seems to be in jaxen, in order to support java 1.4/1.5...
See also jaxen-xpath/jaxen#8

adangel added a commit that referenced this issue Jun 16, 2018

dogfood: fix missing override
Note: the rule is disabled for pmd-xml, refs #1074

adangel added a commit to adangel/pmd that referenced this issue Jun 18, 2018

@jsotuyod jsotuyod added the has:pr label Jun 23, 2018

adangel added a commit to adangel/pmd that referenced this issue Jun 24, 2018

[java] MissingOverrideRule exception when analyzing PMD under Java 9
Fixes pmd#1074

Jaxen is now shaded into pmd-core, without org.w3c.dom.**

adangel added a commit to adangel/pmd that referenced this issue Jun 25, 2018

[java] MissingOverrideRule exception when analyzing PMD under Java 9
Fixes pmd#1074

Jaxen is now shaded into pmd-core, without org.w3c.dom.**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment