Community
Participate
Working Groups
See attached file.
Created attachment 29686 [details] ajcore
Could you append some details about the source you were compiling at the time of the error please? Is it possible to narrow it down to a reproduceable test case that you can append? I can see from the trace that the error is occurring whilst compiling an "if" statement if that is any help... thanks, Adrian.
Created attachment 29687 [details] source excerpt
It's not easy to narrow it down, so I have attached a few sources related, maybe it helps.
Hi, I was trying to narrow down the source code available in this bug when a ParserException occured. I created a simple test case about this problem. I don't know if the bugs are related... I'm using ajde 1.5.0.20051014142856 ------------------------------------------------- package a; public aspect AAA perthis(this(Screen)){} ------------------------------------------------- org.aspectj.weaver.patterns.ParserException at org.aspectj.weaver.patterns.PatternParser.parseDottedNamePattern(PatternParser.java:897) at org.aspectj.weaver.patterns.PatternParser.parseSingleTypePattern(PatternParser.java:695) at org.aspectj.weaver.patterns.PatternParser.parseAtomicTypePattern(PatternParser.java:611) at org.aspectj.weaver.patterns.PatternParser.parseTypePattern(PatternParser.java:572) at org.aspectj.weaver.patterns.PatternParser.parseTypePattern(PatternParser.java:568) at org.aspectj.weaver.patterns.PerThisOrTargetPointcutVisitor.visit(PerThisOrTargetPointcutVisitor.java:140) at org.aspectj.weaver.patterns.ThisOrTargetPointcut.accept(ThisOrTargetPointcut.java:218) at org.aspectj.weaver.patterns.PerThisOrTargetPointcutVisitor.getPerTypePointcut(PerThisOrTargetPointcutVisitor.java:41) at org.aspectj.weaver.PerObjectInterfaceTypeMunger.getTestTypePattern(PerObjectInterfaceTypeMunger.java:46) at org.aspectj.weaver.PerObjectInterfaceTypeMunger.matches(PerObjectInterfaceTypeMunger.java:65) at org.aspectj.weaver.ConcreteTypeMunger.matches(ConcreteTypeMunger.java:57) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:411) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:98) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1464) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1429) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1203) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1021) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:300) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:178) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:367) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:759) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:225) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:151) at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:122) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191) trouble in: public class a.AAA extends java.lang.Object: private static Throwable ajc$initFailureCause public void <init>(): ALOAD_0 // a.AAA this (line 3) INVOKESPECIAL java.lang.Object.<init> ()V constructor-execution(void a.AAA.<init>()) | RETURN constructor-execution(void a.AAA.<init>()) end public void <init>() public static a.AAA aspectOf(Object) org.aspectj.weaver.AjAttribute$AjSynthetic@1a462b9 : ALOAD_0 INSTANCEOF a.AAA$ajcMightHaveAspect IFEQ L1 ALOAD_0 CHECKCAST a.AAA$ajcMightHaveAspect INVOKEINTERFACE a.AAA$ajcMightHaveAspect.ajc$a_AAA$perObjectGet ()La/AAA; DUP IFNULL L0 ARETURN L0: POP L1: NEW org.aspectj.lang.NoAspectBoundException DUP INVOKESPECIAL org.aspectj.lang.NoAspectBoundException.<init> ()V ATHROW end public static a.AAA aspectOf(Object) public static boolean hasAspect(Object) org.aspectj.weaver.AjAttribute$AjSynthetic@1cdf14c : ALOAD_0 INSTANCEOF a.AAA$ajcMightHaveAspect IFEQ L0 ALOAD_0 CHECKCAST a.AAA$ajcMightHaveAspect INVOKEINTERFACE a.AAA$ajcMightHaveAspect.ajc$a_AAA$perObjectGet ()La/AAA; IFNULL L0 ICONST_1 IRETURN L0: ICONST_0 IRETURN end public static boolean hasAspect(Object) public static void ajc$perObjectBind(Object) org.aspectj.weaver.AjAttribute$AjSynthetic@17fbc00 : ALOAD_0 INSTANCEOF a.AAA$ajcMightHaveAspect IFEQ L0 ALOAD_0 CHECKCAST a.AAA$ajcMightHaveAspect INVOKEINTERFACE a.AAA$ajcMightHaveAspect.ajc$a_AAA$perObjectGet ()La/AAA; IFNONNULL L0 ALOAD_0 CHECKCAST a.AAA$ajcMightHaveAspect NEW a.AAA DUP INVOKESPECIAL a.AAA.<init> ()V INVOKEINTERFACE a.AAA$ajcMightHaveAspect.ajc$a_AAA$perObjectSet (La/AAA;)V L0: RETURN end public static void ajc$perObjectBind(Object) end public class a.AAA when weaving type a.AAA when weaving aspects when weaving when batch building BuildConfig[D:\piveta\plugInWorkspace\.metadata\.plugins\org.eclipse.ajdt.core\BugsAspectj113066.generated.lst] #Files=4
I've fixed the parser error that Eduardo demonstrated - I dont think it is related to the original problem. The original problem is this exception: java.lang.NullPointerException at oaoejic.codegen.CodeStream.invokestatic(CodeStream.java:3463) at oaoejic.ast.MessageSend.generateCode(MessageSend.java:137) at oaoejic.ast.EqualExpression.generateOptimizedNonBooleanEqual(Line 349) at oaoejic.ast.EqualExpression.generateOptimizedBoolean(Line 182) at oaoejic.ast.IfStatement.generateCode(IfStatement.java:148) at oaoejic.ast.Block.generateCode(Block.java:58) at oaoejic.ast.IfStatement.generateCode(IfStatement.java:160) at oaoejic.ast.AbstractMethodDeclaration.generateCode(226) at oaoejic.ast.AbstractMethodDeclaration.generateCode(173) at oaoejic.ast.TypeDeclaration.generateCode(TypeDeclaration.java:568) at oaoejic.ast.AspectDeclaration.generateCode(AspectDeclaration.java:279) Line 3463 in CodeStream is: if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) given that the methodbinding is used earlier in the CodeStream.invokestatic method then we know the methodbinding isnt null. So, the returnType for the methodbinding must be null. When I've seen badly formed methodbindings in the code before, it has usually been a sign of syntax error in the code but the compiler is crashing like this before it can be reported. From the stack trace, we can also see this happens whilst generating code for an aspect - and we can see it happens whilst generating code for an if expression. We can't tell if its whilst generating the body of an ITD or generating the body of a regular method because generateCode(ClassFile) isn't overridden in the ITD hierarchy (maybe thats the problem?) Is there any way you can build a subset of your application (take out a few of the aspects) to try and narrow this problem down? Or are they too co-dependent? If that doesnt work then the best we can do is probably a debug build that tells us which method it is crashing on whilst generating code - if I give you a patch for AspectJ to turn on debug, can you apply it and retry creating the problem for me?
I can't narrow it down easily. Also, I forgot to say that it compiles and works with AspectJ 1.2.1 which might be a very important note. If you can send the debug AspectJ version we can try that and send the logs. Another option is that we package that part of the application that does not compile with AspectJ 1.5 and send it to you. Please note that there will be other errors (already seen before) too, despite of that the whole application compiles with AspectJ 1.2.1. But first I have to talk my boss first. levy
I will create a patch to give us more diagnostics. But if you could send me the application source that fails with 1.5 and builds ok with 1.2.1 then that would be a much faster way for me to work - you should probably mail it to me directly rather than attaching to bugzilla.
Created attachment 29855 [details] Debug patch This zip contains 2 classes - you should go into your aspectj installation (possibly c:\aspectj1.5\lib) and create a backup of aspectjtools.jar, then unzip this patch in that directory, giving you an 'org' subfolder. Then update aspectjtools.jar with the two files from the patch, with a command like: jar -uvf aspectjtools.jar org Once patched, when a build occurs we will get a load of diagnostics about the code generation that is occurring - hopefully the bit just before the NPE will tell us which class and which method is causing the problem. If you are using AJDT rather than the command line, then the patch should be applied to ajde.jar in the org.aspectj.ajde plugin in your eclipse plugins directory (backup ajde.jar before patching it)
Created attachment 29856 [details] Debug log with patched compiler
Debug log attached.
thanks for doing that so quickly!! Fails codegen for: invokestatic:NULL TYPE ajc$interMethodDispatch1$com_netvisor_common_UserMessageMixin$ com_netvisor_common_UserMessage$getSeverity(com.netvisor.common.UserMessage) as we can see, the return type is null. The invoke occurs in: actionPerformedExceptionHandler() which is in: com/netvisor/web_framework/components/FormMessages$IFormMessages In actionPerformedExceptionHandler: > UserMessage e = (UserMessage)exception; > > if (e.getSeverity() == UserMessage.MESSAGE) we are blowing up creating the code to invoke getSeverity() on the UserMessage. The original attachment of source doesn't include 'UserMessage' - can you take a look at the ITD that puts getSeverity() onto UserMessage and maybe attach the related source?
There's no magic in there. Please note the can't find int message of your debug log. I think the problem starts from there. Anyway, I have sent you a part of the project which compiles on its own. Try that one if this doesn't help. Thanks for your help, levy ps: BTW: I think the source I have sent is a good test case for the AspectJ compiler. package com.netvisor.common; import java.lang.RuntimeException; public interface UserMessage { public static final int MESSAGE = 0; public static final int WARNING = 1; public static final int ERROR = 2; public Object[] getParams(); public void setParams(Object[] params); public String getUserMessage(); public void setUserMessage(String messageKeyOrText); public int getSeverity(); public void setSeverity(int severity); } package com.netvisor.common; import java.lang.RuntimeException; public abstract aspect UserMessageMixin { declare precedence: UserMessageMixin; private Object[] UserMessage.params; private String UserMessage.message; private int UserMessage.severity; public Object[] UserMessage.getParams() { return params; } public void UserMessage.setParams(Object[] params) { this.params = params; } public String UserMessage.getUserMessage() { return message; } public void UserMessage.setUserMessage(String messageKeyOrText) { this.message = messageKeyOrText; } public int UserMessage.getSeverity() { return severity; } public void UserMessage.setSeverity(int severity) { this.severity = severity; } }
Yes, I agree with you, the 'cant find: int' is the initial problem we need to resolve - given that getSeverity() returns an int. I can't recreate with those two files though. There is only one place in the compiler that can put out that message - so I'm going to attach one more class to patch into your AspectJ - this will give us a stack trace at the point where the type cannot be found. I'll also try recreating it with the code you sent me when it arrives - I assume you sent it to my gmail ID: andrew.clement@gmail.com
Created attachment 29857 [details] Second patch - includes stack at point where type cant be found Apply in the same way as the previous one. With the 'cant find: int' messages there should now be a stack trace indicating how we got into that situation.
Created attachment 29862 [details] Debug log Second log for can't find int message
Did you get my e-mail with the workspace included?
Fix checked in - thanks to Levy I managed to recreate the problem locally. It was to do with our handling of primitives - in this particular case we were 'forgetting' in one case that 'I' was a primitive type and treating it as a reference type (like String or Object). fix will be in next dev build.
Thanks for the fix, I've checked it and it works with Java target version 1.4, but not with 1.5. You can try it by changing the value of <property name="target.java.version" value="1.5"/> in the file AA\Workspace\Repository\common h3\common-build-properties.xml of the package I sent to you. You will receive the following errors (but only with 1.5 target version): [mkdir] Created dir: C:\AA\Workspace\Repository\web-framework\build\web- compiled [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\GridScreen.java:11 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class GridScreen extends Grid [iajc] ^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\GridScreen.java:11 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class GridScreen extends Grid [iajc] ^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\GroupBoxScreen.java:14 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class GroupBoxScreen extends GroupBox [iajc] ^^^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\GroupBoxScreen.java:14 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class GroupBoxScreen extends GroupBox [iajc] ^^^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\Screen.java:3 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public interface Screen extends MutableContent {}; [iajc] ^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\Screen.java:3 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public interface Screen extends MutableContent {}; [iajc] ^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\ScreenTitleMixin.java: 26 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] private interface ScreenTitle extends Screen {}; [iajc] ^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\ScreenTitleMixin.java: 26 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] private interface ScreenTitle extends Screen {}; [iajc] ^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\ScreenWithButtons.java :27 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class ScreenWithButtons extends SimpleScreen [iajc] ^^^^^^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\ScreenWithButtons.java :27 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class ScreenWithButtons extends SimpleScreen [iajc] ^^^^^^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\ScreenWithTitle.java:1 2 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class ScreenWithTitle extends Panel [iajc] ^^^^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\ScreenWithTitle.java:1 2 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class ScreenWithTitle extends Panel [iajc] ^^^^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\SimpleScreen.java:11 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class SimpleScreen extends Panel [iajc] ^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\components\SimpleScreen.java:11 [error] Duplicate methods named actionPerformed with the parameters (ActionEvent) and (ActionEvent) are defined by the type HidingMessagesMixin.IHidingMessages [iajc] public class SimpleScreen extends Panel [iajc] ^^^^^^^^^^^ [iajc] C:\AA\Workspace\Repository\web- framework\src\java\com\netvisor\web_framework\wizard\WizardAspect.java:65 [error] The method add(E) in the type List<E> is not applicable for the arguments (WizardStage) [iajc] this.stages.add(stage);
Interesting! This is exactly the same as bug 110948 which I couldnt reproduce before and so closed as WORKSFORME - I'll take a look at debugging it now I have a test that should show the problem.
Well, the guy who sent that bug just sits next to me... ;-)
*** Bug 110948 has been marked as a duplicate of this bug. ***
what a nightmare. but I've fixed it all now. The duplicate methods stuff is due to an over eager method verifier not allowing for ITDs. That then uncovered a very subtle problem where a ITD that used the raw type list ended up being interpreted later as a reference to the generic type. Fixes all checked in. waiting on build.
Well, thanks a lot. I will try it as soon as the next developer release is available on the web site. Unfortunately or (well I think rather luckily for testing purposes?!) we still have a couple of components to be compiled under Java 1.5 and AspectJ 1.5. These components have never compiled before successfully with 1.5 because they were dependent on the component for which you have just fixed this bug... levy
fixes available in latest dev build.