]> source.dussan.org Git - aspectj.git/commitdiff
Fix 485055: declare @field failing for final String fields (see also Bug 327141)
authorAndy Clement <aclement@pivotal.io>
Tue, 5 Jan 2016 23:44:25 +0000 (15:44 -0800)
committerAndy Clement <aclement@pivotal.io>
Tue, 5 Jan 2016 23:44:25 +0000 (15:44 -0800)
bcel-builder/bcel-src.zip [deleted file]
bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java
lib/bcel/bcel-src.zip
lib/bcel/bcel-verifier.jar
lib/bcel/bcel.jar
tests/bugs188/485055/AspectWithConstant.aj [new file with mode: 0644]
tests/bugs188/485055/ajcore.20160105.151522.218.txt [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc188/Ajc188Tests.java
tests/src/org/aspectj/systemtest/ajc188/ajc188.xml

diff --git a/bcel-builder/bcel-src.zip b/bcel-builder/bcel-src.zip
deleted file mode 100644 (file)
index a3a9951..0000000
Binary files a/bcel-builder/bcel-src.zip and /dev/null differ
index 606beab3ea2e531ca75c3d0265ab6cdd8624f7c3..6a12a8c80731a2ab8b99329159dc5393f668ab70 100644 (file)
@@ -66,6 +66,7 @@ import org.aspectj.apache.bcel.classfile.ConstantInteger;
 import org.aspectj.apache.bcel.classfile.ConstantLong;
 import org.aspectj.apache.bcel.classfile.ConstantObject;
 import org.aspectj.apache.bcel.classfile.ConstantPool;
+import org.aspectj.apache.bcel.classfile.ConstantString;
 import org.aspectj.apache.bcel.classfile.ConstantValue;
 import org.aspectj.apache.bcel.classfile.Field;
 import org.aspectj.apache.bcel.classfile.Utility;
@@ -126,7 +127,6 @@ public class FieldGen extends FieldGenOrMethodGen {
                }
        }
 
-       // TODO setting the constant value is a mess...
        public void setValue(int index) {
                ConstantPool cp = this.cp;
                Constant c = cp.getConstant(index);
@@ -138,6 +138,8 @@ public class FieldGen extends FieldGenOrMethodGen {
                        value = ((ConstantDouble) c).getValue();
                } else if (c instanceof ConstantLong) {
                        value = ((ConstantLong) c).getValue();
+               } else if (c instanceof ConstantString) {
+                       value = ((ConstantString)c).getString(cp);
                } else {
                        value = ((ConstantObject) c).getConstantValue(cp);
                }
index 6e51d79162032b80dd68e6b4d4ae40b69ab88c1f..014a928d42104bbb7bf57fbc0cb11620273007a6 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index 7a722a9057b89f4226d58732765bd5a206db4087..87a86a7958321b92a801fb67ef03dadd8a8db4db 100644 (file)
Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ
index 040e5d0b5ecbefc5f31c8de65b0046656f910b34..197137b65eee0f972dd23c90aea00b146cc3f822 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ
diff --git a/tests/bugs188/485055/AspectWithConstant.aj b/tests/bugs188/485055/AspectWithConstant.aj
new file mode 100644 (file)
index 0000000..0cbbe9c
--- /dev/null
@@ -0,0 +1,13 @@
+import java.lang.annotation.*;
+
+public aspect AspectWithConstant {
+    declare @field : * AspectWithConstant.MAX* : @Loggable;
+public static final String MAXS = "hello";
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Loggable { }
+
+  public static void main(String []argv) throws Exception {
+    System.out.println("MAXS="+MAXS);
+System.out.println(AspectWithConstant.class.getDeclaredField("MAXS").getAnnotation(Loggable.class));
+  }
+}
diff --git a/tests/bugs188/485055/ajcore.20160105.151522.218.txt b/tests/bugs188/485055/ajcore.20160105.151522.218.txt
new file mode 100644 (file)
index 0000000..f5f73af
--- /dev/null
@@ -0,0 +1,156 @@
+---- AspectJ Properties ---
+AspectJ Compiler 1.8.7 built on Wednesday Sep 9, 2015 at 21:19:30 GMT
+---- Dump Properties ---
+Dump file: ajcore.20160105.151522.218.txt
+Dump reason: java.lang.ClassCastException
+Dump on exception: true
+Dump at exit condition: abort
+---- Exception Information ---
+java.lang.ClassCastException: org.aspectj.apache.bcel.classfile.ConstantString cannot be cast to org.aspectj.apache.bcel.classfile.ConstantObject
+       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.BcelWeaver.getClassFilesFor(BcelWeaver.java:1440)
+       at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1402)
+       at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1155)
+       at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514)
+       at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:447)
+       at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:432)
+       at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:103)
+       at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:902)
+       at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:545)
+       at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:458)
+       at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036)
+       at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
+       at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
+       at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:114)
+       at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
+       at org.aspectj.tools.ajc.Main.run(Main.java:371)
+       at org.aspectj.tools.ajc.Main.runMain(Main.java:248)
+       at org.aspectj.tools.ajc.Main.main(Main.java:84)
+---- System Properties ---
+java.runtime.name=Java(TM) SE Runtime Environment
+sun.boot.library.path=/Users/aclement/jvms/jdk180u60/Home/jre/lib
+java.vm.version=25.60-b23
+gopherProxySet=false
+java.vm.vendor=Oracle Corporation
+java.vendor.url=http://java.oracle.com/
+path.separator=:
+java.vm.name=Java HotSpot(TM) 64-Bit Server VM
+file.encoding.pkg=sun.io
+user.country=US
+sun.java.launcher=SUN_STANDARD
+sun.os.patch.level=unknown
+java.vm.specification.name=Java Virtual Machine Specification
+user.dir=/Users/aclement/gits/org.aspectj/tests/bugs188/485055
+java.runtime.version=1.8.0_60-b27
+java.awt.graphicsenv=sun.awt.CGraphicsEnvironment
+java.endorsed.dirs=/Users/aclement/jvms/jdk180u60/Home/jre/lib/endorsed
+os.arch=x86_64
+java.io.tmpdir=/var/folders/cn/p3n4rh_n6z7gm6zwk53mtfc80000gp/T/
+line.separator=
+
+java.vm.specification.vendor=Oracle Corporation
+os.name=Mac OS X
+sun.jnu.encoding=UTF-8
+java.library.path=/Users/aclement/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
+java.specification.name=Java Platform API Specification
+java.class.version=52.0
+sun.management.compiler=HotSpot 64-Bit Tiered Compilers
+os.version=10.11.1
+http.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
+user.home=/Users/aclement
+user.timezone=America/Vancouver
+java.awt.printerjob=sun.lwawt.macosx.CPrinterJob
+file.encoding=UTF-8
+java.specification.version=1.8
+java.class.path=/Users/aclement/installs/aspectj187/lib/aspectjtools.jar:/Users/aclement/jvms/jdk180u60/Home/lib/tools.jar:.:/Users/aclement/.m2/repository/org/springframework/spring-test/4.2.3.RELEASE/spring-test-4.2.3.RELEASE.jar:/Users/aclement/.m2/repository/org/springframework/spring-context/4.2.3.RELEASE/spring-context-4.2.3.RELEASE.jar:/Users/aclement/installs/aspectj187/lib/aspectjrt.jar
+user.name=aclement
+java.vm.specification.version=1.8
+sun.java.command=org.aspectj.tools.ajc.Main -1.5 AspectWithConstant.aj
+java.home=/Users/aclement/jvms/jdk180u60/Home/jre
+sun.arch.data.model=64
+user.language=en
+java.specification.vendor=Oracle Corporation
+awt.toolkit=sun.lwawt.macosx.LWCToolkit
+java.vm.info=mixed mode
+java.version=1.8.0_60
+java.ext.dirs=/Users/aclement/Library/Java/Extensions:/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
+sun.boot.class.path=/Users/aclement/jvms/jdk180u60/Home/jre/lib/resources.jar:/Users/aclement/jvms/jdk180u60/Home/jre/lib/rt.jar:/Users/aclement/jvms/jdk180u60/Home/jre/lib/sunrsasign.jar:/Users/aclement/jvms/jdk180u60/Home/jre/lib/jsse.jar:/Users/aclement/jvms/jdk180u60/Home/jre/lib/jce.jar:/Users/aclement/jvms/jdk180u60/Home/jre/lib/charsets.jar:/Users/aclement/jvms/jdk180u60/Home/jre/lib/jfr.jar:/Users/aclement/jvms/jdk180u60/Home/jre/classes
+java.vendor=Oracle Corporation
+file.separator=/
+java.vendor.url.bug=http://bugreport.sun.com/bugreport/
+sun.io.unicode.encoding=UnicodeBig
+sun.cpu.endian=little
+socksNonProxyHosts=local|*.local|169.254/16|*.169.254/16
+ftp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
+sun.cpu.isalist=
+---- Command Line ---
+-1.5
+AspectWithConstant.aj
+---- Full Classpath ---
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/resources.jar(3501583 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/rt.jar(66555254 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/sunrsasign.jar(missing)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/jsse.jar(625764 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/jce.jar(114730 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/charsets.jar(3133473 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/jfr.jar(555268 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/classes(missing)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/cldrdata.jar(3860522 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/dnsns.jar(8286 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/jaccess.jar(44516 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/jfxrt.jar(18570861 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/localedata.jar(1178935 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/nashorn.jar(2014239 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/sunec.jar(39771 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/sunjce_provider.jar(278680 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/sunpkcs11.jar(250826 bytes)
+/Users/aclement/jvms/jdk180u60/Home/jre/lib/ext/zipfs.jar(68848 bytes)
+/System/Library/Java/Extensions/AppleScriptEngine.jar(6476 bytes)
+/System/Library/Java/Extensions/dns_sd.jar(17780 bytes)
+/System/Library/Java/Extensions/j3daudio.jar(1223496 bytes)
+/System/Library/Java/Extensions/j3dcore.jar(1157355 bytes)
+/System/Library/Java/Extensions/j3dutils.jar(685308 bytes)
+/System/Library/Java/Extensions/jai_codec.jar(275499 bytes)
+/System/Library/Java/Extensions/jai_core.jar(1544542 bytes)
+/System/Library/Java/Extensions/mlibwrapper_jai.jar(41239 bytes)
+/System/Library/Java/Extensions/MRJToolkit.jar(12847 bytes)
+/System/Library/Java/Extensions/vecmath.jar(127640 bytes)
+/Users/aclement/jvms/jdk180u60/Home/lib/tools.jar(18194868 bytes)
+/Users/aclement/gits/org.aspectj/tests/bugs188/485055/.(2 entries)
+/Users/aclement/.m2/repository/org/springframework/spring-test/4.2.3.RELEASE/spring-test-4.2.3.RELEASE.jar(562284 bytes)
+/Users/aclement/.m2/repository/org/springframework/spring-context/4.2.3.RELEASE/spring-context-4.2.3.RELEASE.jar(1088916 bytes)
+/Users/aclement/installs/aspectj187/lib/aspectjrt.jar(116927 bytes)
+---- Compiler Messages ---
+error at (no source information available)
+/Users/aclement/gits/org.aspectj/tests/bugs188/485055/AspectWithConstant.aj:0::0 Internal compiler error: java.lang.ClassCastException: org.aspectj.apache.bcel.classfile.ConstantString cannot be cast to org.aspectj.apache.bcel.classfile.ConstantObject at org.aspectj.apache.bcel.generic.FieldGen.setValue(FieldGen.java:142)
+abort ABORT -- (ClassCastException) org.aspectj.apache.bcel.classfile.ConstantString cannot be cast to org.aspectj.apache.bcel.classfile.ConstantObject
+org.aspectj.apache.bcel.classfile.ConstantString cannot be cast to org.aspectj.apache.bcel.classfile.ConstantObject
+java.lang.ClassCastException: org.aspectj.apache.bcel.classfile.ConstantString cannot be cast to org.aspectj.apache.bcel.classfile.ConstantObject
+       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.BcelWeaver.getClassFilesFor(BcelWeaver.java:1440)
+       at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1402)
+       at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1155)
+       at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514)
+       at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:447)
+       at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:432)
+       at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:103)
+       at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:902)
+       at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:545)
+       at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:458)
+       at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036)
+       at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
+       at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
+       at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:114)
+       at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
+       at org.aspectj.tools.ajc.Main.run(Main.java:371)
+       at org.aspectj.tools.ajc.Main.runMain(Main.java:248)
+       at org.aspectj.tools.ajc.Main.main(Main.java:84)
+
index 1a5f5a4656da8cc7d19bec09d46e60164e09489e..c2f5e888c5d43aeaa1748fdd0a4374b399e35d4e 100644 (file)
@@ -21,6 +21,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  */
 public class Ajc188Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testClassCast() throws Exception {
+               runTest("classcast");
+       }
+       
        public void testAnnotationDiscoveryNpe() throws Exception {
                runTest("annotation discovery npe");
        }
index a9844f79f07797b8fbee0ebba1f87ad070c82ad2..685b502405ff8d059179fa4dbb8fa1baf3db52fc 100644 (file)
@@ -2,6 +2,16 @@
 
 <suite>
 
+
+   <ajc-test dir="bugs188/485055" title="classcast">
+     <compile files="AspectWithConstant.aj" options="-1.5"/>
+     <run class="AspectWithConstant">
+     <stdout>
+     <line text="MAXS=hello"/>
+     <line text="@AspectWithConstant$Loggable()"/>
+     </stdout></run>
+   </ajc-test>
+   
 <ajc-test dir="bugs188/484941" title="annotation discovery npe">
 <compile files="Test2.java" options="-1.8 -XnoInline"/>
 </ajc-test>