Bug 252198 - Around advice on Initialization of Fields in Interfaces: ClassFormatError: around body has illegal modifiers: 0x101A
Summary: Around advice on Initialization of Fields in Interfaces: ClassFormatError: ar...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.2   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.6.3   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-27 10:49 EDT by Bruno De Fraine CLA
Modified: 2008-10-30 15:13 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.