Bug 252198

Summary: Around advice on Initialization of Fields in Interfaces: ClassFormatError: around body has illegal modifiers: 0x101A
Product: [Tools] AspectJ Reporter: Bruno De Fraine <bruno>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: 1.6.2   
Target Milestone: 1.6.3   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Bruno De Fraine CLA 2008-10-27 10:49:05 EDT
The following aspect:

interface Foo {
	public static final Object dummy = new Object();
}

public aspect Test {
	Object around(): call(Object.new(..)) {
		return proceed();
	}
	
	public static void main(String[] args) {
		System.out.println(Foo.dummy);
	}
}

Compiles without error, but produces the following error at runtime:

Exception in thread "main" java.lang.ClassFormatError: Method init$_aroundBody0 in class Foo has illegal modifiers: 0x101A
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
	at Test.main(Test.aj:12)

Initialization of Fields in Interfaces is described here:
http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html#40720

The problem might be that you cannot put methods in interfaces, but then it seems AspectJ should anticipate this and complain while compiling.
Comment 1 Andrew Clement CLA 2008-10-27 10:55:06 EDT
Similar to bug 163005. and as I wrote in comment 2 there:

"recognize this problem and dont weave methods into an interface"

try and look at this for 1.6.3
Comment 2 Andrew Clement CLA 2008-10-30 15:13:21 EDT
163005 now fixed.  this situation will now produce an xlint and skip the join point.