You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2023/04/04 10:27:12 UTC

[Bug 66552] New: Depend task does not handle invokeDynamic constant pool entries - java.lang.ClassFormatError: Invalid Constant Pool entry Type 17

https://bz.apache.org/bugzilla/show_bug.cgi?id=66552

            Bug ID: 66552
           Summary: Depend task does not handle invokeDynamic constant
                    pool entries - java.lang.ClassFormatError: Invalid
                    Constant Pool entry Type 17
           Product: Ant
           Version: 1.10.8
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
          Assignee: notifications@ant.apache.org
          Reporter: j.michelberger@gmail.com
  Target Milestone: ---

Seems that the depend task does not handle classfiles with the invokeDynamic
properly:
java.lang.ClassFormatError: Invalid Constant Pool entry Type 17
        at
org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPoolEntry.readEntry(ConstantPoolEntry.java:179)
        at
org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPool.read(ConstantPool.java:67)
        at
org.apache.tools.ant.taskdefs.optional.depend.ClassFile.read(ClassFile.java:73)
        at
org.apache.tools.ant.taskdefs.optional.depend.AntAnalyzer.determineDependencies(AntAnalyzer.java:78)
        at
org.apache.tools.ant.util.depend.AbstractAnalyzer.getClassDependencies(AbstractAnalyzer.java:105)
        at
org.apache.tools.ant.taskdefs.optional.depend.Depend.determineDependencies(Depend.java:325)
        at
org.apache.tools.ant.taskdefs.optional.depend.Depend.execute(Depend.java:647)

ant -version
Apache Ant(TM) version 1.10.8 compiled on May 10 2020

java -version
openjdk version "17.0.6" 2023-01-17 LTS
OpenJDK Runtime Environment (build 17.0.6+10-LTS)
OpenJDK 64-Bit Server VM (build 17.0.6+10-LTS, mixed mode, sharing)

A quick view in the latest ConstantPoolEntry.java showed, that there is no
constant for "Entry Type 17" is defined, so a classfile delivering the 17 ends
in the default block fireing the above Exception.

The constant seems to be defined since JDK11, but the Exception are not shown
building with same Ant and JDK11.
https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.4

Seems JDK17 produces class files using that constants.
I have currently no isolated code/script to reproduce.

Found an similar issue, but with slight different constant in the bug database.
https://bz.apache.org/bugzilla/show_bug.cgi?id=54090

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 66552] Depend task does not handle Dynamic constant pool entries - java.lang.ClassFormatError: Invalid Constant Pool entry Type 17

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66552

Jaikiran Pai <ja...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |1.10.15

--- Comment #4 from Jaikiran Pai <ja...@apache.org> ---
Thank you for the patch. I've merged it to the Ant master branch and will be
available in the next Ant release 1.10.15 (no specific timeline).

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 66552] Depend task does not handle invokeDynamic constant pool entries - java.lang.ClassFormatError: Invalid Constant Pool entry Type 17

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66552

Joerg Michelberger <j....@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |Windows 10

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 66552] Depend task does not handle Dynamic constant pool entries - java.lang.ClassFormatError: Invalid Constant Pool entry Type 17

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66552

--- Comment #2 from Jaikiran Pai <ja...@apache.org> ---
Thank you for all these details. I don't have previous experience with the
depend task, but looking at what it does, it appears that this task/code would
have to keep a close track of the changes that might happen with class file
format and content, across Java releases.

I will check the code in a bit more detail to see what needs to be added to at
least make it not fail in recent Java versions.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 66552] Depend task does not handle Dynamic constant pool entries - java.lang.ClassFormatError: Invalid Constant Pool entry Type 17

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66552

--- Comment #3 from Joerg Michelberger <j....@gmail.com> ---
I have provided a pull request with a fix:
https://github.com/apache/ant/pull/204

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 66552] Depend task does not handle Dynamic constant pool entries - java.lang.ClassFormatError: Invalid Constant Pool entry Type 17

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66552

Joerg Michelberger <j....@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |j.michelberger@gmail.com

--- Comment #1 from Joerg Michelberger <j....@gmail.com> ---
Created attachment 38539
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38539&action=edit
A project demonstrating the problem.

Attachment contains a NetBeans demo project based on the project of Jan Lahoda
(https://bz.apache.org/bugzilla/show_bug.cgi?id=54090).

The issue appears in combination with junit test and Jacoco pre-instrumented
class files put in the directory location beside the test class. The demo
contains the class and a test. The preparation phase for test execution put the
pre-instrumented class file in the directory scope of the test class, so ANT
Depend task will pick it up in build/test/classes.

The project is (manually) extended doing the Jacoco pre-instrumenting task by
overwriting the -pre-init target in build.xml defining the taskdef for
jacocoant and extending the -init-macrodef-junit-prototype-without-module and
-init-macrodef-junit-prototype-with-module target with the jacoco:instrument
phase in nbproject/build-impl.xml.

Java source and target is set to JDK11, Compiler is JDK17.

Download current
https://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.9/jacoco-0.8.9.zip
and copy jacocoant.jar in the projects root.

Execute Test and Test again to rise the bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 66552] Depend task does not handle Dynamic constant pool entries - java.lang.ClassFormatError: Invalid Constant Pool entry Type 17

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66552

Joerg Michelberger <j....@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
            Summary|Depend task does not handle |Depend task does not handle
                   |invokeDynamic constant pool |Dynamic constant pool
                   |entries -                   |entries -
                   |java.lang.ClassFormatError: |java.lang.ClassFormatError:
                   |Invalid Constant Pool entry |Invalid Constant Pool entry
                   |Type 17                     |Type 17

-- 
You are receiving this mail because:
You are the assignee for the bug.