A quick observation, the use of cflow(within(...)) is going to advise a lot of places with calls to increment/decrement flow counters, perhaps too many. Do you think this variant would capture your intent?
pointcut insideTrustedPackage(): within(com.icw.ehf.aspectj.lab.service..*) && execution(* *(..)); It would insert the counter inc/dec code in far fewer places. (maybe need a '|| staticinitialization()' bit in there too). I've seen this pattern before, and I wonder if really it is something we should fix inside AspectJ. That said, it still may violate this JVM restriction. Have you tried it with recent Java 8 builds, is it the same issue? Please raise a bug against AspectJ - it'll take some thought to address this I think. cheers, Andy On 5 September 2014 06:45, <jochen.koh...@icw.de> wrote: > Hi AspectJ Users ! > > I encountered a strange problem with one of my existing aspects after > updating to the latest Java 7 version (jdk 1.7.0_67). With this JDK, I > receive a "java.lang.VerifyError: Bad <init> method call from after the > start of a try block" when one of my instrumented classes is used. > > The verification Error is produced by the following change in the JDK ( > http://hg.openjdk.java.net/jdk7u/jdk7u/hotspot/rev/458f18560343). > > I created a small sample project which reproduces the problem and attached > it to this eMail. > My production scenario is: Modify the result of a call to a particular > object if the call originates from an untrusted package. > > Therefor, I created the following Aspect: > > public aspect Experiment { > pointcut insideTrustedPackage(): > within(com.icw.ehf.aspectj.lab.service..*); > > Object around(com.icw.ehf.aspectj.lab.pojo.SomePojo input): > !cflow(insideTrustedPackage()) && this(input) { > System.out.println("from untrusted package " + > thisJoinPoint.toString()); > return proceed(input); > } > > } > > If I use JDK version 1.7.0_55, everything works as expected. However, when > using JDK 1.7.0_67, running the unit test in my example project results in > the following VerifyError > > java.lang.VerifyError: Bad <init> method call from after the start of a > try block > Exception Details: > Location: > com/icw/ehf/aspectj/lab/service/SomeService.<init>()V @30: > invokespecial > Reason: > Error exists in the bytecode > Bytecode: > 0000000: 2ab2 002b b600 3000 a700 0e3a 0ab2 002b > 0000010: b600 3319 0abf 00b2 002b b600 3300 b700 > 0000020: 09b2 002b b600 30b2 002b b600 30b2 002b > 0000030: b600 30b2 000b a700 0c4d b200 2bb6 0033 > 0000040: 2cbf 00b2 002b b600 3300 1211 b200 2bb6 > 0000050: 0030 b600 13a7 000e 3a04 b200 2bb6 0033 > 0000060: 1904 bf00 b200 2bb6 0033 00a7 000e 3a06 > 0000070: b200 2bb6 0033 1906 bfb2 002b b600 33a7 > 0000080: 000e 3a08 b200 2bb6 0033 1908 bfb2 002b > 0000090: b600 33b1 > Exception Handler Table: > bci [82, 85] => handler: 88 > bci [51, 54] => handler: 57 > bci [45, 110] => handler: 110 > bci [39, 130] => handler: 130 > bci [7, 8] => handler: 11 > Stackmap Table: > same_locals_1_stack_item_frame(@11,Object[#57]) > same_locals_1_stack_item_frame(@22,UninitializedThis) > full_frame(@57,{Object[#1]},{Object[#57]}) > same_locals_1_stack_item_frame(@66,Object[#20]) > same_locals_1_stack_item_frame(@88,Object[#57]) > same_frame(@99) > same_locals_1_stack_item_frame(@110,Object[#57]) > same_frame(@121) > same_locals_1_stack_item_frame(@130,Object[#57]) > same_frame(@141) > > at > com.icw.ehf.aspectj.lab.ExperimentAspectTest.test(ExperimentAspectTest.java:13) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) > at > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) > at org.junit.runners.ParentRunner.run(ParentRunner.java:309) > at > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) > at > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) > > I disassembled the bytecode of the SomeService.class which I added to the > very end of this eMail. > In this mnemonic representation of the bytecocde, I can see, that the > actual .<init>() Method call is not the first Java statement in the > constructor, which the comment in the JDK checkin indicates is no longer > considered valid. > > Unfortunately, I haven't found any useful information regarding this > problem in the archives. > > Has anybody already encountered this issue ? > > Or even better, does anybody have a solution for me ? > > Your help would be much appreciated ! > > Thanks in advance, > > Jochen Kohler | Software Architect | Managed & Personalized HealthCare > InterComponentWare AG | Altrottstraße 31 | 69190 Walldorf (Baden) | > Germany > Tel.: +49 (0) 6227 385 38 86 | Fax: +49 (0) 6227 385 471 > jochen.koh...@icw.de | www.icw.de > > Disassembled ByteCode: > $ javap -c -s bin/com/icw/ehf/aspectj/lab/service/SomeService.class > Compiled from "SomeService.java" > public class com.icw.ehf.aspectj.lab.service.SomeService { > public com.icw.ehf.aspectj.lab.service.SomeService(); > Signature: ()V > Code: > 0: aload_0 > 1: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 4: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 7: nop > 8: goto 22 > 11: astore 10 > 13: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 16: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 19: aload 10 > 21: athrow > 22: nop > 23: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 26: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 29: nop > 30: invokespecial #9 // Method > java/lang/Object."<init>":()V > 33: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 36: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 39: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 42: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 45: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 48: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 51: getstatic #11 // Field > java/lang/System.out:Ljava/io/PrintStream; > 54: goto 66 > 57: astore_2 > 58: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 61: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 64: aload_2 > 65: athrow > 66: nop > 67: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 70: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 73: nop > 74: ldc #17 // String Constructor > SomeService > 76: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 79: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 82: invokevirtual #19 // Method > java/io/PrintStream.println:(Ljava/lang/String;)V > 85: goto 99 > 88: astore 4 > 90: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 93: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 96: aload 4 > 98: athrow > 99: nop > 100: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 103: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 106: nop > 107: goto 121 > 110: astore 6 > 112: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 115: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 118: aload 6 > 120: athrow > 121: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 124: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 127: goto 141 > 130: astore 8 > 132: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 135: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 138: aload 8 > 140: athrow > 141: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 144: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 147: return > Exception table: > from to target type > 82 85 88 Class java/lang/Throwable > 51 54 57 Class java/lang/Throwable > 45 110 110 Class java/lang/Throwable > 39 130 130 Class java/lang/Throwable > 7 8 11 Class java/lang/Throwable > > public com.icw.ehf.aspectj.lab.pojo.SomePojo retreiveSomePojo(); > Signature: ()Lcom/icw/ehf/aspectj/lab/pojo/SomePojo; > Code: > 0: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 3: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 6: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 9: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 12: getstatic #11 // Field > java/lang/System.out:Ljava/io/PrintStream; > 15: goto 27 > 18: astore_2 > 19: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 22: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 25: aload_2 > 26: athrow > 27: nop > 28: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 31: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 34: nop > 35: ldc #31 // String > SomeService#retreiveSomePojo > 37: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 40: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 43: invokevirtual #19 // Method > java/io/PrintStream.println:(Ljava/lang/String;)V > 46: goto 60 > 49: astore 4 > 51: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 54: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 57: aload 4 > 59: athrow > 60: nop > 61: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 64: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 67: nop > 68: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 71: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 74: new #33 // class > com/icw/ehf/aspectj/lab/pojo/SomePojo > 77: dup > 78: invokespecial #35 // Method > com/icw/ehf/aspectj/lab/pojo/SomePojo."<init>":()V > 81: goto 95 > 84: astore 6 > 86: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 89: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 92: aload 6 > 94: athrow > 95: nop > 96: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 99: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 102: nop > 103: astore 9 > 105: goto 119 > 108: astore 8 > 110: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 113: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 116: aload 8 > 118: athrow > 119: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 122: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 125: aload 9 > 127: areturn > Exception table: > from to target type > 74 81 84 Class java/lang/Throwable > 43 46 49 Class java/lang/Throwable > 12 15 18 Class java/lang/Throwable > 6 108 108 Class java/lang/Throwable > > static {}; > Signature: ()V > Code: > 0: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 3: invokevirtual #48 // Method > org/aspectj/runtime/internal/CFlowCounter.inc:()V > 6: goto 31 > 9: astore_1 > 10: aload_1 > 11: instanceof #53 // class > java/lang/ExceptionInInitializerError > 14: ifeq 22 > 17: aload_1 > 18: checkcast #53 // class > java/lang/ExceptionInInitializerError > 21: athrow > 22: nop > 23: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 26: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 29: aload_1 > 30: athrow > 31: getstatic #43 // Field > Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter; > 34: invokevirtual #51 // Method > org/aspectj/runtime/internal/CFlowCounter.dec:()V > 37: return > Exception table: > from to target type > 6 9 9 Class java/lang/Throwable > } > > > InterComponentWare AG: > Vorstand: Peter Kirschbauer (Vors.), Matthias Glück > Aufsichtsratsvors.: Prof. Dr. Christof Hettich > Firmensitz: 69190 Walldorf, Altrottstraße 31 > AG Mannheim HRB 351761 / USt.-IdNr.: DE 198388516 [image: Follow > @icwinc on Twitter] > <https://twitter.com/intent/follow?original_referer=emailfooter&partner=undefined®ion=follow_link&screen_name=icwinc&tw_p=followbutton&variant=2.0> > [image: InterComponentWare AG] > <http://www.linkedin.com/company/intercomponentware-ag> [image: > InterComponentWare AG] > <https://www.xing.com/companies/intercomponentwareag> > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://dev.eclipse.org/mailman/listinfo/aspectj-users >
_______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/aspectj-users