Bug 76727 - NullPointerException at AsmRelationshipProvider.checkerMunger
Summary: NullPointerException at AsmRelationshipProvider.checkerMunger
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-20 23:36 EDT by Masayuki Takahashi CLA
Modified: 2004-11-23 11:08 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Masayuki Takahashi CLA 2004-10-20 23:36:40 EDT
Hoge.java
package jp.co.techfirm.masayuki.study.aspectj;
import java.io.IOException;

import org.apache.log4j.Logger;

/**
 * Aspectをweavingされるクラス
 * @author masayuki
 */
public class Hoge extends HogeHoge{
	
	static Logger log;
	static{
		try{
			log = Logger.getLogger(Hoge.class.getName( ));
			log.info( "start Hoge static constructor" );
			log.info( "end Hoge static constructor" );
		}catch( Exception e ){
			e.printStackTrace();
		}
	}
	
	private String fielda;
	private boolean flag = false;

	public Hoge(){
		log.info( "start Hoge constructor" );
		log.info( "end Hoge constructor" );
	}
	
	public Hoge( String field ){
		this.fielda = field;
	}
	
	public void method1(){
		log.info( "start method1" );
		log.info( "end method1" );
		this.flag = true;
	}
	
	public int method2(){
		log.info( "start method2" );
		log.info( "end method2" );
		return 500;
	}
	
	public String method3( String foo ){
		log.info( "start method3" );
		log.info( "end method3" );
		return foo;
	}
	
	public String method4( String foo, String bar ){
		log.info( "start method4" );
		log.info( "end method4" );
		return foo + bar;
	}
	
	public void method5(){
		log.info( "start method5" );
		throw new RuntimeException( "test" );
	}
	
	public String method6() throws IOException{
		log.info( "start method6" );
		throw new IOException( "test" );
	}
	
	public String method7(){
		log.info( "start method7" );
		fielda = "hoge";
		return fielda;
	}
	
	public Object method8( Object o ){
		log.info( "start method8" );
		return o;
	}
	
	public boolean flagState(){
		return flag;
	}
}
--

HogeHoge.java
--
package jp.co.techfirm.masayuki.study.aspectj;

import org.apache.log4j.Logger;

public class HogeHoge{

	static Logger log = Logger.getLogger(HogeHoge.class.getName( ));

	public HogeHoge(){
		log.info( "start HogeHoge constructor" );
		log.info( "end HogeHoge constructor" );
	}
	
}
--

Test.java
--

package jp.co.techfirm.masayuki.study.aspectj.declare;

import java.util.Arrays;

public class Test {
	public static void main( String[] argv ){
		System.out.println( 
				Test.class.getName() + " entends " + 
				Test.class.getSuperclass() + " implements " + 
				Arrays.asList( Test.class.getInterfaces() ) 
		);
		System.out.println( 
				Sub.class.getName() + " entends " + 
				Sub.class.getSuperclass() + " implements " + 
				Arrays.asList( Sub.class.getInterfaces() ) 
		);
		System.out.println( 
				Child.class.getName() + " entends " + 
				Child.class.getSuperclass() + " implements " + 
				Arrays.asList( Child.class.getInterfaces() ) 
		);
	}

	public void do_someting(){	
	}

}
--

Sub.java
--
package jp.co.techfirm.masayuki.study.aspectj.declare;

public class Sub extends Test {

}
--

Child.java
--
package jp.co.techfirm.masayuki.study.aspectj.declare;

public class Child extends Test {

}

AddConstructor.java
--
package jp.co.techfirm.masayuki.study.aspectj.intertype;
import jp.co.techfirm.masayuki.study.aspectj.*;
import org.apache.log4j.Logger;

public aspect AddConstructor {
	static Logger log = Logger.getLogger( "aspect" );

	public HogeHoge.new( String str ){
		log.info( "HogeHoge( String str )." );
		log.info( "str: " + str );
	}

}
--

AddMethod.java
--
package jp.co.techfirm.masayuki.study.aspectj.intertype;
import jp.co.techfirm.masayuki.study.aspectj.*;
import org.apache.log4j.Logger;

public aspect AddMethod {
	static Logger log = Logger.getLogger( "aspect" );

	public void HogeHoge.hello(){
		log.info( "hello HogeHoge." );
	}

}
--

AddValue.java
--
package jp.co.techfirm.masayuki.study.aspectj.intertype;
import jp.co.techfirm.masayuki.study.aspectj.*;
import org.apache.log4j.Logger;

public aspect AddValue {
	static Logger log = Logger.getLogger( "aspect" );

	public String HogeHoge.addedValue = "hogehoge";
	
}
--

I compiled these sources with ant and ajc. so

--
     [iajc] java.lang.NullPointerException
     [iajc]     at org.aspectj.weaver.AsmRelationshipProvider.checkerMunger(Asm
elationshipProvider.java:51)
     [iajc]     at org.aspectj.weaver.Checker.match(Checker.java:58)
     [iajc]     at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeave
.java:985)
     [iajc]     at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeave
.java:791)
     [iajc]     at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeave
.java:291)
     [iajc]     at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeave
.java:77)
     [iajc]     at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:417

     [iajc]     at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:390

     [iajc]     at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:316

     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.weaveA
dGenerateClassFiles(AjBuildManager.java:256)
     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuil
(AjBuildManager.java:156)
     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchB
ild(AjBuildManager.java:70)
     [iajc]     at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:
9)
     [iajc]     at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java
53)
     [iajc]     at org.aspectj.tools.ajc.Main.run(Main.java:217)
     [iajc]     at org.aspectj.tools.ajc.Main.runMain(Main.java:155)
     [iajc]     at org.aspectj.tools.ant.taskdefs.AjcTask.executeInSameVM(AjcTa
k.java:1047)
     [iajc]     at org.aspectj.tools.ant.taskdefs.AjcTask.execute(AjcTask.java:
04)
     [iajc]     at org.apache.tools.ant.Task.perform(Task.java:341)
     [iajc]     at org.apache.tools.ant.Target.execute(Target.java:309)
     [iajc]     at org.apache.tools.ant.Target.performTasks(Target.java:336)
     [iajc]     at org.apache.tools.ant.Project.executeTarget(Project.java:1339

     [iajc]     at org.apache.tools.ant.Project.executeTargets(Project.java:125
)
     [iajc]     at org.apache.tools.ant.Main.runBuild(Main.java:609)
     [iajc]     at org.apache.tools.ant.Main.start(Main.java:196)
     [iajc]     at org.apache.tools.ant.Main.main(Main.java:235)
--
why?
Comment 1 Andrew Clement CLA 2004-10-21 09:20:28 EDT
Can I confirm you were running AspectJ 1.2 for this test?  I've tried recreating
it on that level of compiler and can't get it to fail.  The stack for the
failure indicates a problem occurred in the CheckerMunger which should only be
involved if a program uses either a 'declare warning' or 'declare error' - and I
can't see one of those in the sources below - is there another class somewhere
on your system that might contain one?

A few things we can do.  First, and most simple, is to download the latest dev
version of AspectJ and see if the problem still occurs - we are about to release
the latest dev version as AspectJ 1.2.1 in the next few days.  You can download
it from:

http://download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT.jar

If you would rather I carried on investigating, can you attach the ANT file you
are using to build the program - or at least let me know the options you are
specifying to the iajc task.

thanks.
Comment 2 Andrew Clement CLA 2004-10-22 06:30:23 EDT
After receiving the full failing program via email (thanks for that!) - I have
recreated the failure.  The problem occurs if using AspectJ 1.1.1 - it doesn't
fail with AspectJ1.2 or the latest development builds of AspectJ.  Can you grab
the latest AspectJ and have another go?  If you think you are on AspectJ1.2 -
can you make sure the versions of the aspectJ libraries in the lib folder in
your build environment (used by your ANT script) match those from an AspectJ1.2
distribution?  thanks.

When it works I get:

C:\ajtemp\aspectJstudy>ant clean ajc runMethod1
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\ajtemp\aspectJstudy\classes

ajc:
     [iajc]
C:\ajtemp\aspectJstudy\src\jp\co\techfirm\masayuki\study\aspectj\declare\Test.java:37
wa
rning Underbar '_' should be excluded from the names of method
     [iajc] }
     [iajc] ^
     [iajc]     method-execution(void
jp.co.techfirm.masayuki.study.aspectj.declare.Test.do_someting
())
     [iajc]     see also:
C:\ajtemp\aspectJstudy\aspect\jp\co\techfirm\masayuki\study\aspectj\declar
e\DeclareWarning.java:19
     [iajc]
C:\ajtemp\aspectJstudy\aspect\jp\co\techfirm\masayuki\study\aspectj\intertype\AddConstru
ctor.java:17 warning Underbar '_' should be excluded from the names of method
     [iajc] public aspect AddConstructor {
     [iajc]               ^^^^^^^^^^^^^
     [iajc]     method-execution(java.lang.Object[]
jp.co.techfirm.masayuki.study.aspectj.intertype.
AddConstructor.ajc$preInterConstructor$jp_co_techfirm_masayuki_study_aspectj_intertype_AddConstructo
r$jp_co_techfirm_masayuki_study_aspectj_HogeHoge(java.lang.String))
     [iajc]     see also:
C:\ajtemp\aspectJstudy\aspect\jp\co\techfirm\masayuki\study\aspectj\declar
e\DeclareWarning.java:19
     [iajc]
C:\ajtemp\aspectJstudy\aspect\jp\co\techfirm\masayuki\study\aspectj\intertype\AddValue.j
ava:20 warning Underbar '_' should be excluded from the names of method
     [iajc] public String HogeHoge.addedValue = "hogehoge";
     [iajc] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     [iajc]     method-execution(void
jp.co.techfirm.masayuki.study.aspectj.intertype.AddValue.ajc$i
nterFieldInit$jp_co_techfirm_masayuki_study_aspectj_intertype_AddValue$jp_co_techfirm_masayuki_study
_aspectj_HogeHoge$addedValue(jp.co.techfirm.masayuki.study.aspectj.HogeHoge))
     [iajc]     see also:
C:\ajtemp\aspectJstudy\aspect\jp\co\techfirm\masayuki\study\aspectj\declar
e\DeclareWarning.java:19

runMethod1:
     [java] Hoge.<clinit> - start Hoge static constructor
     [java] Hoge.<clinit> - end Hoge static constructor
     [java] HogeHoge.<init> - start HogeHoge constructor
     [java] HogeHoge.<init> - end HogeHoge constructor
     [java] Hoge.<init> - start Hoge constructor
     [java] Hoge.<init> - end Hoge constructor
     [java] Hoge.method1 - start method1
     [java] Hoge.method1 - end method1

BUILD SUCCESSFUL
Total time: 9 seconds
C:\ajtemp\aspectJstudy>
Comment 3 Andrew Clement CLA 2004-10-27 14:54:14 EDT
Hi.  Are you able to confirm this bug doesn't occur on the latest version of
AspectJ?
thanks.
Comment 4 Andrew Clement CLA 2004-11-23 11:08:46 EST
Tidying up bugzilla. This bug is already believed to be fixed - please reopen if
it still happens for you on the latest AspectJ.