History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JANINO-99
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Arno Unkrig
Reporter: Varghese C V
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Janino

ConcurrentModificationException due to instance variable of Class type initialized using a class literal

Created: 17/Aug/07 07:17 PM   Updated: 31/Aug/07 07:05 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment: janino 2.5.9, jdk 5

Testcase included: yes


 Description  « Hide
The following statement :
new SimpleCompiler().cook(new StringReader("class Test{Class c = String.class;}"));

throws Exception in thread "main" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.next(AbstractList.java:420)
at org.codehaus.janino.UnitCompiler.initializeInstanceVariablesAndInvokeInstanceInitializers(UnitCompiler.java:4220)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1523)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:231)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:112)
at org.codehaus.janino.UnitCompiler$1.visitPackageMemberClassDeclaration(UnitCompiler.java:85)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:676)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:91)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:69)
at org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:396)
at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:224)
at org.codehaus.janino.Cookable.cook(Cookable.java:68)
at org.codehaus.janino.Cookable.cook(Cookable.java:60)

Static variables don't throw any exceptions though.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Arno Unkrig - 21/Aug/07 03:56 PM
Hi Varghese,

I can't fix this right now because I'm not at home, but if you change the first two lines of UnitCompiler.initializeInstanceVariablesAndInvokeInstanceInitializers() from

for (Iterator it = cd.getDeclaringClass().variableDeclaratorsAndInitializers.iterator(); it.hasNext();) {
    Java.TypeBodyDeclaration tbd = (Java.TypeBodyDeclaration) it.next();

to

for (int i = 0; i < cd.getDeclaringClass().variableDeclaratorsAndInitializers.size(); ++i) {
    Java.TypeBodyDeclaration tbd = (Java.TypeBodyDeclaration) cd.getDeclaringClass().variableDeclaratorsAndInitializers.get(i);

, then it should work fine... please complain if not!

CU

Arno


Varghese C V - 24/Aug/07 07:11 AM
Hi Arno,

It works fine after applying the changes.

Thanks
Varghese C V


Arno Unkrig - 31/Aug/07 07:05 PM
Yep, the fix will go into 2.5.10 (no release date scheduled yet).