Community
Participate
Working Groups
Created attachment 258948 [details] error dialog "Interneal Compiler Error:.." public aspect AspectWithStringConstant { /* * Just compile this aspect in eclipse luna in an AspectJ project... * then an error dialog box(see ErrorDialog.pdf atached) * "Interneal Compiler Error:.." with the following details will arise: * java.lang.ClassCastException at org.aspectj.apache.bcel.generic.FieldGen.setValue(FieldGen.java:142) at org.aspectj.apache.bcel.generic.FieldGen.<init>(FieldGen.java:115) at org.aspectj.weaver.bcel.BcelField.getField(BcelField.java:233) at org.aspectj.weaver.bcel.LazyClassGen.writeBack(LazyClassGen.java:522) at org.aspectj.weaver.bcel.LazyClassGen.getJavaClassBytesIncludingReweavable(LazyClassGen.java:697) at org.aspectj.weaver.bcel.Bc ... error: ClassCastException thrown: org.aspectj.apache.bcel.classfile.ConstantString cannot be cast to org.aspectj.apache.bcel.classfile.ConstantObject * * In the "RESOLVED" "FIXED" Bug 327141 the exception was related to an * "static final int" field. * For this case and for "long" and "double" final fields the Bug was * fixed by Andrew Clement. * * In our case here, for final fields of type String, the * "java.lang.ClassCastException" still occurs. * * My guess is, that there is a general issue with types which allow only to * create immutable objects like the types int, long, double etc. * and of course String. * * I couldn't find the piece of code which was fixed by Andrew, so I couldn't * check whether it is possible or not, but maybe it is reasonable to * re-engineer that fix in a bit more abstract fashion in order to make it * work for all fields of "immutable-forcing"-types. * * Remark: I run also few other tests with fields of non * "immutable-forcing"-type. * There came no "java.lang.ClassCastException...". * So I assume the Bugis only left in the case the field * type is final String. * */ declare @field : String AspectWithStringConstant.SOME_NAME : @Loggable; public final String SOME_NAME = ""; @interface Loggable { } public static void main(String[] args) { System.out.println("success"); } }
Fixed. I had to extend the if statement in the BCEL FieldGen code to handle the ConstantString class. Thanks for doing the digging to find that other bug, using that I very quickly found the old test cases and code to update.