Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help debugging ClassFormatError #116

Open
joel-costigliola opened this issue Jan 6, 2018 · 5 comments
Open

Help debugging ClassFormatError #116

joel-costigliola opened this issue Jan 6, 2018 · 5 comments

Comments

@joel-costigliola
Copy link

Hi,

I'm struggling debugging this issue assertj/assertj#1146.
Is there a way to find out which is the duplicate method mentioned in the exception ?

Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.assertj.core.internal.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:459)
at org.assertj.core.internal.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
... 39 more
Caused by: java.lang.ClassFormatError: Duplicate method name&signature in class file org/assertj/core/api/ObjectArrayAssert$$EnhancerByCGLIB$$2a693b8d$$EnhancerByCGLIB$$e518c7e6
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)

Thanks in advance

@joel-costigliola joel-costigliola changed the title Help debugging Help debugging ClassFormatError Jan 6, 2018
@joel-costigliola
Copy link
Author

joel-costigliola commented Jan 6, 2018

I guess the faulty method is extracting, there are several versions of it in ObjectArrayAssert:

  1. public <U> ObjectArrayAssert<U> extracting(Extractor<? super ELEMENT, U> extractor)
  2. public final ObjectArrayAssert<Tuple> extracting(Function<ELEMENT, ?>... extractors)
  3. public ObjectArrayAssert<Object> extracting(String fieldOrProperty)
  4. public ObjectArrayAssert<Tuple> extracting(String... propertiesOrFields)
  5. public <P> ObjectArrayAssert<P> extracting(String fieldOrProperty, Class<P> type)
  6. public <U, EX extends Exception> ObjectArrayAssert<U> extracting(ThrowingExtractor<? super ELEMENT, U, EX> extractor)

would the error be caused by 3. and 4. ?

@raphw
Copy link
Member

raphw commented Jan 6, 2018

I checked the reproduction and the problem is cglib proxying another cglib proxied class:

org.assertj.core.api.ObjectArrayAssert$$EnhancerByCGLIB$$30eb9e74$$EnhancerByCGLIB$$ffbccd53 extends org.assertj.core.api.ObjectArrayAssert$$EnhancerByCGLIB$$30eb9e74.

This causes a duplicate registration of the callback cglib-internal methods whose names are not randomized.

@joel-costigliola
Copy link
Author

joel-costigliola commented Jan 7, 2018

thanks @raphw!
would byte buddy be able to handle such a case ?

@joel-costigliola
Copy link
Author

It seems byte-buddy handles that case correctly 😸

@raphw
Copy link
Member

raphw commented Jan 7, 2018

Byte Buddy is based on a different model then cglib. Byte Buddy adds none of its own types into proxy classes to avoid this problem but also solve issues like OSGi (and now Java 9 module) boundary violations. This is why this should not be an issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants