Hi Andy,
thanks for your answer - much appreciated !
Adding "&& execution(* *(..))" to my pointcut definition solves the VerifyError. I haven't completely verified, that the modification does not cause any undesired side effects on the business modules, but it looks promising.
Executing the unit test in my example project using aspectj 1.8.2 rather than 1.7.4 makes no difference - the VerifyError still exists.
I have, as you suggested, raised a bug describing the issue, mainly because in my humble opinion, the aspectj compiler should not produce bytecode that is considered invalid by the oracle JVM. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=443477).
Thanks for your Help !
Jochen
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
[email protected] | www.icw.de
[email protected] wrote: -----
To: [email protected]
From: Andy Clement
Sent by: [email protected]
Date: 09/05/2014 06:25PM
Subject: Re: [aspectj-users] "java.lang.VerifyError: Bad <init> method call from after the start of a try block" with jdk_1.7.0_67
From: Andy Clement
Sent by: [email protected]
Date: 09/05/2014 06:25PM
Subject: Re: [aspectj-users] "java.lang.VerifyError: Bad <init> method call from after the start of a try block" with jdk_1.7.0_67
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, <[email protected]> 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 VerifyErrorjava.lang.VerifyError: Bad <init> method call from after the start of a try blockException Details:Location:com/icw/ehf/aspectj/lab/service/SomeService.<init>()V @30: invokespecialReason:Error exists in the bytecodeBytecode:0000000: 2ab2 002b b600 3000 a700 0e3a 0ab2 002b0000010: b600 3319 0abf 00b2 002b b600 3300 b7000000020: 09b2 002b b600 30b2 002b b600 30b2 002b0000030: b600 30b2 000b a700 0c4d b200 2bb6 00330000040: 2cbf 00b2 002b b600 3300 1211 b200 2bb60000050: 0030 b600 13a7 000e 3a04 b200 2bb6 00330000060: 1904 bf00 b200 2bb6 0033 00a7 000e 3a060000070: b200 2bb6 0033 1906 bfb2 002b b600 33a70000080: 000e 3a08 b200 2bb6 0033 1908 bfb2 002b0000090: b600 33b1Exception Handler Table:bci [82, 85] => handler: 88bci [51, 54] => handler: 57bci [45, 110] => handler: 110bci [39, 130] => handler: 130bci [7, 8] => handler: 11Stackmap 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
[email protected] | www.icw.deDisassembled ByteCode:$ javap -c -s bin/com/icw/ehf/aspectj/lab/service/SomeService.classCompiled from "SomeService.java"public class com.icw.ehf.aspectj.lab.service.SomeService {public com.icw.ehf.aspectj.lab.service.SomeService();Signature: ()VCode:0: aload_01: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;4: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V7: nop8: goto 2211: astore 1013: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;16: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V19: aload 1021: athrow22: nop23: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;26: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V29: nop30: invokespecial #9 // Method java/lang/Object."<init>":()V33: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;36: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V39: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;42: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V45: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;48: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V51: getstatic #11 // Field java/lang/System.out:Ljava/io/PrintStream;54: goto 6657: astore_258: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;61: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V64: aload_265: athrow66: nop67: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;70: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V73: nop74: ldc #17 // String Constructor SomeService76: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;79: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V82: invokevirtual #19 // Method java/io/PrintStream.println:(Ljava/lang/String;)V85: goto 9988: astore 490: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;93: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V96: aload 498: athrow99: nop100: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;103: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V106: nop107: goto 121110: astore 6112: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;115: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V118: aload 6120: athrow121: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;124: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V127: goto 141130: astore 8132: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;135: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V138: aload 8140: athrow141: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;144: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V147: returnException table:from to target type82 85 88 Class java/lang/Throwable51 54 57 Class java/lang/Throwable45 110 110 Class java/lang/Throwable39 130 130 Class java/lang/Throwable7 8 11 Class java/lang/Throwablepublic 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:()V6: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;9: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V12: getstatic #11 // Field java/lang/System.out:Ljava/io/PrintStream;15: goto 2718: astore_219: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;22: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V25: aload_226: athrow27: nop28: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;31: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V34: nop35: ldc #31 // String SomeService#retreiveSomePojo37: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;40: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V43: invokevirtual #19 // Method java/io/PrintStream.println:(Ljava/lang/String;)V46: goto 6049: astore 451: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;54: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V57: aload 459: athrow60: nop61: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;64: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V67: nop68: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;71: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V74: new #33 // class com/icw/ehf/aspectj/lab/pojo/SomePojo77: dup78: invokespecial #35 // Method com/icw/ehf/aspectj/lab/pojo/SomePojo."<init>":()V81: goto 9584: astore 686: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;89: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V92: aload 694: athrow95: nop96: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;99: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V102: nop103: astore 9105: goto 119108: astore 8110: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;113: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V116: aload 8118: athrow119: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;122: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V125: aload 9127: areturnException table:from to target type74 81 84 Class java/lang/Throwable43 46 49 Class java/lang/Throwable12 15 18 Class java/lang/Throwable6 108 108 Class java/lang/Throwablestatic {};Signature: ()VCode:0: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;3: invokevirtual #48 // Method org/aspectj/runtime/internal/CFlowCounter.inc:()V6: goto 319: astore_110: aload_111: instanceof #53 // class java/lang/ExceptionInInitializerError14: ifeq 2217: aload_118: checkcast #53 // class java/lang/ExceptionInInitializerError21: athrow22: nop23: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;26: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V29: aload_130: athrow31: getstatic #43 // Field Experiment.ajc$cflowCounter$0:Lorg/aspectj/runtime/internal/CFlowCounter;34: invokevirtual #51 // Method org/aspectj/runtime/internal/CFlowCounter.dec:()V37: returnException table:from to target type6 9 9 Class java/lang/Throwable}
_______________________________________________
aspectj-users mailing list
[email protected]
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
[email protected]
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
[email protected]
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 [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/aspectj-users
