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

             Bug ID: 59556
            Summary: AntClassLoader.findClassInComponents does not work
                     with JDK9-b116+
            Product: Ant
            Version: 1.9.7
           Hardware: All
                 OS: All
             Status: NEW
           Severity: blocker
           Priority: P2
          Component: Core
           Assignee: notifications@ant.apache.org
           Reporter: vincent.privat@gmail.com

We have an Ant project that calls some Java code in build.xml as follows:

     <target name="epsg" depends="epsg-compile">
         <touch file="${epsg.output}"/>
         <java classname="BuildProjectionDefinitions" failonerror="true">
             <sysproperty key="java.awt.headless" value="true"/>
             <classpath>
                 <pathelement path="${base.dir}"/>
                 <pathelement path="${proj-classpath}"/>
                 <pathelement path="${proj-build.dir}"/>
             </classpath>
             <arg value="${base.dir}"/>
         </java>
     </target>

the code involves reflection:

/**
  * Proj Factory that creates instances from a given class.
  */
public class ClassProjFactory implements ProjFactory {

     private final Class<? extends Proj> projClass;

     /**
      * Constructs a new {@code ClassProjFactory}.
      * @param projClass projection class
      */
     public ClassProjFactory(Class<? extends Proj> projClass) {
         this.projClass = projClass;
     }

     @Override
     public Proj createInstance() {
         Proj proj = null;
         try {
             proj = projClass.getConstructor().newInstance();
         } catch (ReflectiveOperationException e) {
             throw new RuntimeException(e);
         }
         return proj;
     }
}

This code works fine with Java 7, 8, and Java 9 up to build 114.

It fails with builds 116 and 118 with this stacktrace:

java.lang.NoClassDefFoundError: jdk/internal/reflect/ConstructorAccessorImpl
     at jdk.internal.misc.Unsafe.defineClass0(java.base@9-ea/Native Method)
     at jdk.internal.misc.Unsafe.defineClass(java.base@9-ea/Unsafe.java:1125)
     at
jdk.internal.reflect.ClassDefiner.defineClass(java.base@9-ea/ClassDefiner.java:63)
     at
jdk.internal.reflect.MethodAccessorGenerator$1.run(java.base@9-ea/MethodAccessorGenerator.java:400)
     at
jdk.internal.reflect.MethodAccessorGenerator$1.run(java.base@9-ea/MethodAccessorGenerator.java:394)
     at java.security.AccessController.doPrivileged(java.base@9-ea/Native
Method)
     at
jdk.internal.reflect.MethodAccessorGenerator.generate(java.base@9-ea/MethodAccessorGenerator.java:393)
     at
jdk.internal.reflect.MethodAccessorGenerator.generateConstructor(java.base@9-ea/MethodAccessorGenerator.java:92)
     at
jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(java.base@9-ea/NativeConstructorAccessorImpl.java:55)
     at
jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(java.base@9-ea/DelegatingConstructorAccessorImpl.java:45)
     at
java.lang.reflect.Constructor.newInstance(java.base@9-ea/Constructor.java:453)
     at
org.openstreetmap.josm.data.projection.proj.ClassProjFactory.createInstance(ClassProjFactory.java:23)
     at
org.openstreetmap.josm.data.projection.Projections.getBaseProjection(Projections.java:220)
     at
BuildProjectionDefinitions.doInclude(BuildProjectionDefinitions.java:159)
     at BuildProjectionDefinitions.buildList(BuildProjectionDefinitions.java:78)
     at BuildProjectionDefinitions.main(BuildProjectionDefinitions.java:52)
     at
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native
Method)
     at
jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
     at
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:531)
     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:218)
     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:153)
     at org.apache.tools.ant.taskdefs.Java.run(Java.java:833)
     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:227)
     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:136)
     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:109)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
     at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
     at
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:531)
     at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     at org.apache.tools.ant.Task.perform(Task.java:348)
     at org.apache.tools.ant.Target.execute(Target.java:435)
     at org.apache.tools.ant.Target.performTasks(Target.java:456)
     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
     at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
     at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
     at org.apache.tools.ant.Main.runBuild(Main.java:854)
     at org.apache.tools.ant.Main.startAnt(Main.java:236)
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.lang.ClassNotFoundException:
jdk.internal.reflect.ConstructorAccessorImpl
     at
org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1388)
     at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1337)
     at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1095)
     at java.lang.ClassLoader.loadClass(java.base@9-ea/ClassLoader.java:419)
     ... 42 more

Latest JDK 9 Early Access can be found here: https://jdk9.java.net/download/

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

Search Discussions

  • Bugzilla at May 14, 2016 at 7:55 pm
    https://bz.apache.org/bugzilla/show_bug.cgi?id=59556

    Vincent Privat <vincent.privat@gmail.com> changed:

                What |Removed |Added
    ----------------------------------------------------------------------------
                Priority|P2 |P1

    --
    You are receiving this mail because:
    You are the assignee for the bug.
  • Bugzilla at May 21, 2016 at 12:52 am
    https://bz.apache.org/bugzilla/show_bug.cgi?id=59556

    --- Comment #1 from Vincent Privat <vincent.privat@gmail.com> ---
    Looks caused by https://bugs.openjdk.java.net/browse/JDK-8137058 fixed in b115.

    --
    You are receiving this mail because:
    You are the assignee for the bug.
  • Bugzilla at May 21, 2016 at 2:51 pm
    https://bz.apache.org/bugzilla/show_bug.cgi?id=59556

    --- Comment #2 from Vincent Privat <vincent.privat@gmail.com> ---
    Solution found: add fork="true" to java task.

    --
    You are receiving this mail because:
    You are the assignee for the bug.
  • Bugzilla at May 22, 2016 at 2:15 pm
    https://bz.apache.org/bugzilla/show_bug.cgi?id=59556

    Stefan Bodewig <bodewig@apache.org> changed:

                What |Removed |Added
    ----------------------------------------------------------------------------
                  Status|NEW |RESOLVED
              Resolution|--- |WONTFIX

    --- Comment #3 from Stefan Bodewig <bodewig@apache.org> ---
    Thank you for reporting this, I'm afraid there isn't anything Ant could do. And
    many thanks for sharing your "fix".

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnotifications @
categoriesant
postedMay 14, '16 at 12:15p
activeMay 22, '16 at 2:15p
posts5
users1
websiteant.apache.org

1 user in discussion

Bugzilla: 5 posts

People

Translate

site design / logo © 2018 Grokbase