JDK-8026845 : Exception in thread "main" java.lang.IllegalAccessError: tried to access method java.lang.Object.clone()Ljava/lang/Object
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs25
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2013-10-18
  • Updated: 2013-10-18
  • Resolved: 2013-10-18
Related Reports
Duplicate :  
Description
Apache reported the following regression issue with jdk 8 ea b111:

Exception in thread "main" java.lang.IllegalAccessError: tried to access method java.lang.Object.clone()Ljava/lang/Object; from class TestCloneInterface
        at TestCloneInterface.test(TestCloneInterface.java:15)
        at TestCloneInterface.main(TestCloneInterface.java:19)

The testcase TestCloneInterface.java is attached.  Testcase appear to pass with jdk 8 ea b109 (and b110).


Below is email from Apache:
----------------------------------------------------------------------------------------------------
Hi,

I was able to reproduce with a simple test case that emulates the UIMA code.
See attached test case, just compile it with any JDK and run with b111:

With Java 7 or JDK8b109:

> javac TestCloneInterface.java
> java TestCloneInterface
>

With JDK8b111:

> java TestCloneInterface
Exception in thread "main" java.lang.IllegalAccessError: tried to access method java.lang.Object.clone()Ljava/lang/Object; from class TestCloneInterface
        at TestCloneInterface.test(TestCloneInterface.java:15)
        at TestCloneInterface.main(TestCloneInterface.java:19)
>

The bug happens if the clone() method is declared in a superinterface only. Without the additional interface inbetween, test passes.
Instead of the real interface (the "o" local variable, which is of type "FoobarIntf") it checks access flags on "this", which is of type "TestCloneInterface".

Uwe

-----
Uwe Schindler
uschindler@apache.org 
Apache Lucene PMC Chair / Committer
Bremen, Germany
http://lucene.apache.org/


-----------------------------------------------------------------------------------------------------------------



Comments
Duplicate of JDK-8026394
18-10-2013

Here is original email from Apache that explains how the bug was found originally. The bug was found by Apache UIMA tests. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ we found a new bug in 8 b111, not appearing in Java 7 and Java 8 b109: It seems to be related to one recent commit, reproduces all the time (reproduces with bytecode compiled with JDK8b111 and ran with JDK8b111, but also with bytecode compiled with JDK7 and ran with JDK8b111). I am trying to understand what's happening, but it looks like the patch fails to check the access flags of the method on the correct instance/type/whatever. This is the commit that I think causes this: http://hg.openjdk.java.net/jdk8/jdk8/hotspot/rev/36b97be47bde Issue: https://bugs.openjdk.java.net/browse/JDK-8011311 What happens: When running Apache Lucene's UIMA tests (UIMA is foreign code, not part of Lucene): > cd lucene/analysis/uima > ant test *All* tests fail here: java.lang.IllegalAccessError: tried to access method java.lang.Object.clone()Ljava/lang/Object; from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase at __randomizedtesting.SeedInfo.seed([BC36C2DC5FC6C107:4A94D14D35381F88]:0) at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.initialize(AnalysisEngineImplBase.java:163) at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:127) at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94) at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62) at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:267) at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:335) at org.apache.lucene.analysis.uima.ae.BasicAEProvider.getAE(BasicAEProvider.java:73) at org.apache.lucene.analysis.uima.BaseUIMATokenizer.analyzeInput(BaseUIMATokenizer.java:63) at org.apache.lucene.analysis.uima.UIMAAnnotationsTokenizer.initializeIterator(UIMAAnnotationsTokenizer.java:60) at org.apache.lucene.analysis.uima.UIMAAnnotationsTokenizer.incrementToken(UIMAAnnotationsTokenizer.java:74) at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:98) [...] Tests pass with previous versions of JDK8. As this is not our code, it is hard for me to understand (UIMA uses maaaaaaaaaany interfaces...). I just found out: This code fails: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.uima/uimaj-core/2.3.1/org/apache/uima/analysis_engine/impl/AnalysisEngineImplBase.java#163 The interface used here declares clone() correctly and public: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.uima/uimaj-core/2.3.1/org/apache/uima/resource/metadata/MetaDataObject.java#MetaDataObject.clone%28%29 To me it looks like the access flag check is done on the "this" instance and not on the local variable "md". "md" is definitely not of type org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase like the Exception suggests. The class in the Exception for sure does not implement clone, so it is protected (from Object). It looks like hotspot mixes up the call stack. How should I proceed with opening bug reports? As first step, I think I will now download Apache UIMA and run their tests. This failure is not related to Apache Lucene its just a referenced library in one of our modules. Uwe ----- Uwe Schindler uschindler@apache.org Apache Lucene PMC Chair / Committer Bremen, Germany http://lucene.apache.org/ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
18-10-2013