Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] ClassFormatError in certain situations

Hello.

I have an issue that comes from a combination of things and leads to
java.lang.ClassFormatError at runtime. Here is the most minimalistic
package to reproduce this problem:

public aspect Aspect pertypewithin(*){}

public interface GenericService<T extends SomeInterface> {
	public void doStuff(T t);
}

public class GenericServiceImpl<T extends SomeInterface> implements
GenericService<T> {
	public void doStuff(T t) {}
}

public interface SomeInterface {}

public class SomeServiceImpl extends GenericServiceImpl<SomeInterface> {
	@Override
	public void doStuff(SomeInterface someInterface) {
	}
}

public class Main {
	public static void main(String[] args) {
		new SomeServiceImpl();
	}
}

And here is what I get right after I have done clean and ran my little
test.

Exception in thread "main" java.lang.ClassFormatError: Repetitive method
name/signature in class file SomeServiceImpl
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	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:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at Main.main(Main.java:3)

Any of the following will remove this issue:

1) Removing pertypewithin(*) from the aspect
2) Renaming SomeServiceImpl to ASomeServiceImpl, or anything so is
before GenericServiceImpl alphabetically.
3) Compiling SomeServiceImpl again after cleaning (whitespace
modification and save). 
4) Commenting the doStuff method out from SomeServiceImpl class.
5) Changing method signature in SomeServiceImpl to take T (T extends
SomeInterface) as the argument.

The difference between working and not working .class files I get is
that there is an additional method descriptor in the one that does not
work:

  // Method descriptor #15 (LSomeInterface;)V
  // Stack: 2, Locals: 2
  public bridge void doStuff(SomeInterface arg0);
    0  aload_0
    1  aload_1
    2  invokevirtual SomeServiceImpl.doStuff(SomeInterface) : void [36]
    5  return
      Line numbers:
        [pc: 0, line: 1]

And here are my versions:
Eclipse Platform

Version: 3.4.1
Build id: M20080911-1700

Eclipse AspectJ Development Tools

Version: 1.6.1.20081104192500
AspectJ version: 1.6.3.20081028135200

java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Server VM (build 1.5.0_16-b02, mixed mode)

Has anyone experienced and maybe resolved this issue? I tried to browse
the bug reports but couldn't find anything that seemed like a match.

Thanks in advance,
Jouni Lantinen



Back to the top