irobertson / pojomatic

Pojomatic provides configurable implementations of the equals(Object), hashCode() and toString() methods inherited from java.lang.Object.
30 stars 7 forks source link

java.lang.UnsupportedOperationException: This feature requires ASM7 #14

Closed bulatnig closed 6 years ago

bulatnig commented 6 years ago

pojomatic-2.1.0 openjdk version "11.0.1" 2018-10-16 OpenJDK Runtime Environment 18.9 (build 11.0.1+13) OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

With asm-6.2.1: Caused by: java.lang.UnsupportedOperationException at org.objectweb.asm.ClassVisitor.visitNestHostExperimental(ClassVisitor.java:158) at org.objectweb.asm.ClassReader.accept(ClassReader.java:541) at org.objectweb.asm.ClassReader.accept(ClassReader.java:391) at org.pojomatic.internal.PropertyClassVisitor.visitClass(PropertyClassVisitor.java:46) at org.pojomatic.internal.ClassProperties.extractClassProperties(ClassProperties.java:183) at org.pojomatic.internal.ClassProperties.walkHierarchy(ClassProperties.java:161) at org.pojomatic.internal.ClassProperties.(ClassProperties.java:81) at org.pojomatic.internal.ClassProperties.(ClassProperties.java:26) at org.pojomatic.internal.ClassProperties$1.create(ClassProperties.java:39) at org.pojomatic.internal.ClassProperties$1.create(ClassProperties.java:36) at org.pojomatic.internal.SelfPopulatingMap.tryCreatingValue(SelfPopulatingMap.java:46) at org.pojomatic.internal.SelfPopulatingMap.get(SelfPopulatingMap.java:22) at org.pojomatic.internal.ClassProperties.forClass(ClassProperties.java:64) at org.pojomatic.internal.PojomatorFactory.makePojomatorChecked(PojomatorFactory.java:33) at org.pojomatic.internal.PojomatorFactory.access$000(PojomatorFactory.java:16) at org.pojomatic.internal.PojomatorFactory$1.run(PojomatorFactory.java:22) at org.pojomatic.internal.PojomatorFactory$1.run(PojomatorFactory.java:19) at java.base/java.security.AccessController.doPrivileged(Native Method) at org.pojomatic.internal.PojomatorFactory.makePojomator(PojomatorFactory.java:19) at org.pojomatic.Pojomatic$1.create(Pojomatic.java:77) at org.pojomatic.Pojomatic$1.create(Pojomatic.java:72) at org.pojomatic.internal.SelfPopulatingMap.tryCreatingValue(SelfPopulatingMap.java:46) at org.pojomatic.internal.SelfPopulatingMap.get(SelfPopulatingMap.java:22) at org.pojomatic.Pojomatic.pojomator(Pojomatic.java:178) at org.pojomatic.Pojomatic.toString(Pojomatic.java:93)

With asm-7.0: Caused by: java.lang.UnsupportedOperationException: This feature requires ASM7 at org.objectweb.asm.ClassVisitor.visitNestHost(ClassVisitor.java:150) at org.objectweb.asm.ClassReader.accept(ClassReader.java:541) at org.objectweb.asm.ClassReader.accept(ClassReader.java:391) at org.pojomatic.internal.PropertyClassVisitor.visitClass(PropertyClassVisitor.java:46) at org.pojomatic.internal.ClassProperties.extractClassProperties(ClassProperties.java:183) at org.pojomatic.internal.ClassProperties.walkHierarchy(ClassProperties.java:161) at org.pojomatic.internal.ClassProperties.(ClassProperties.java:81) at org.pojomatic.internal.ClassProperties.(ClassProperties.java:26) at org.pojomatic.internal.ClassProperties$1.create(ClassProperties.java:39) at org.pojomatic.internal.ClassProperties$1.create(ClassProperties.java:36) at org.pojomatic.internal.SelfPopulatingMap.tryCreatingValue(SelfPopulatingMap.java:46) at org.pojomatic.internal.SelfPopulatingMap.get(SelfPopulatingMap.java:22) at org.pojomatic.internal.ClassProperties.forClass(ClassProperties.java:64) at org.pojomatic.internal.PojomatorFactory.makePojomatorChecked(PojomatorFactory.java:33) at org.pojomatic.internal.PojomatorFactory.access$000(PojomatorFactory.java:16) at org.pojomatic.internal.PojomatorFactory$1.run(PojomatorFactory.java:22) at org.pojomatic.internal.PojomatorFactory$1.run(PojomatorFactory.java:19) at java.base/java.security.AccessController.doPrivileged(Native Method) at org.pojomatic.internal.PojomatorFactory.makePojomator(PojomatorFactory.java:19) at org.pojomatic.Pojomatic$1.create(Pojomatic.java:77) at org.pojomatic.Pojomatic$1.create(Pojomatic.java:72) at org.pojomatic.internal.SelfPopulatingMap.tryCreatingValue(SelfPopulatingMap.java:46) at org.pojomatic.internal.SelfPopulatingMap.get(SelfPopulatingMap.java:22) at org.pojomatic.Pojomatic.pojomator(Pojomatic.java:178) at org.pojomatic.Pojomatic.toString(Pojomatic.java:93)

Failing code example pojomatic_bug_14.tar.gz

irobertson commented 6 years ago

Would you mind providing an example of a java file that leads to this error? I'd like to have a test case for this, so that I can verify I'm fixing it : ).

bulatnig commented 6 years ago

@irobertson I've added simplest example reproducing error pojomatic_bug_14.tar.gz

ghost commented 6 years ago

I have the same issue. If I look in the PropertyVisitorClass, it use ASM4:

class PropertyClassVisitor extends ClassVisitor {

  private final Map<PropertyRole, Map<String, PropertyElement>> fieldsMap;
  private final Map<PropertyRole, Map<String, PropertyElement>> methodsMap;
  private final Map<PropertyRole, List<PropertyElement>> sortedProperties = makeProperties();

  PropertyClassVisitor(
      Map<PropertyRole, Map<String, PropertyElement>> fieldsMap,
      Map<PropertyRole, Map<String, PropertyElement>> methodsMap) {
    super(Opcodes.ASM4);   //  <====== ******************************************** HERE
    this.fieldsMap = fieldsMap;
    this.methodsMap = methodsMap;

  }
irobertson commented 6 years ago

Fixed in pojomatic-2.2.0