| @@ -31,6 +31,11 @@ Fixed bugs: | |||||
| * <cab> died with a NullPointerException since Ant 1.10.2. | * <cab> died with a NullPointerException since Ant 1.10.2. | ||||
| Bugzilla Report 62335 | Bugzilla Report 62335 | ||||
| * The <depend> task would fail with | |||||
| "java.lang.ClassFormatError: Invalid Constant Pool entry Type 19" while | |||||
| parsing a module-info.class. This is now fixed. | |||||
| Bug reported by Simon IJskes https://issues.apache.org/jira/browse/NETBEANS-781 | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -33,6 +33,11 @@ | |||||
| <property name="src3.dir" value="src3"/> | <property name="src3.dir" value="src3"/> | ||||
| <property name="src4.dir" value="src4"/> | <property name="src4.dir" value="src4"/> | ||||
| <property name="src5.dir" value="src5"/> | <property name="src5.dir" value="src5"/> | ||||
| <property name="src6.dir" value="src6"/> | |||||
| <condition property="atleast.java9"> | |||||
| <javaversion atleast="9"/> | |||||
| </condition> | |||||
| <target name="help"> | <target name="help"> | ||||
| <echo>This buildfile is used as part of Ant's test suite.</echo> | <echo>This buildfile is used as part of Ant's test suite.</echo> | ||||
| @@ -193,4 +198,10 @@ | |||||
| <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/> | <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/> | ||||
| <fileset id="result" dir="${classes.dir}"/> | <fileset id="result" dir="${classes.dir}"/> | ||||
| </target> | </target> | ||||
| <target name="testmoduleinfo" if="${atleast.java9}"> | |||||
| <mkdir dir="${output}/java9"/> | |||||
| <javac srcdir="${src6.dir}" destdir="${output}/java9" source="9" target="9"/> | |||||
| <depend srcdir="${src6.dir}" destdir="${output}/java9"/> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -0,0 +1,22 @@ | |||||
| /* | |||||
| Licensed to the Apache Software Foundation (ASF) under one or more | |||||
| contributor license agreements. See the NOTICE file distributed with | |||||
| this work for additional information regarding copyright ownership. | |||||
| The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
| (the "License"); you may not use this file except in compliance with | |||||
| the License. You may obtain a copy of the License at | |||||
| http://www.apache.org/licenses/LICENSE-2.0 | |||||
| Unless required by applicable law or agreed to in writing, software | |||||
| distributed under the License is distributed on an "AS IS" BASIS, | |||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| See the License for the specific language governing permissions and | |||||
| limitations under the License. | |||||
| */ | |||||
| public class Foo { | |||||
| public static void main(final String[] args) { | |||||
| System.out.println("foo"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,3 @@ | |||||
| module dummy { | |||||
| requires java.base; | |||||
| } | |||||
| @@ -71,6 +71,9 @@ public abstract class ConstantPoolEntry { | |||||
| /** Tag value for InvokeDynamic entries*/ | /** Tag value for InvokeDynamic entries*/ | ||||
| public static final int CONSTANT_INVOKEDYNAMIC = 18; | public static final int CONSTANT_INVOKEDYNAMIC = 18; | ||||
| /** Tag value for CONSTANT_Module_info entry */ | |||||
| public static final int CONSTANT_MODULEINFO = 19; | |||||
| /** | /** | ||||
| * This entry's tag which identifies the type of this constant pool | * This entry's tag which identifies the type of this constant pool | ||||
| * entry. | * entry. | ||||
| @@ -162,6 +165,9 @@ public abstract class ConstantPoolEntry { | |||||
| case CONSTANT_INVOKEDYNAMIC: | case CONSTANT_INVOKEDYNAMIC: | ||||
| cpInfo = new InvokeDynamicCPInfo(); | cpInfo = new InvokeDynamicCPInfo(); | ||||
| break; | break; | ||||
| case CONSTANT_MODULEINFO: | |||||
| cpInfo = new ModuleCPInfo(); | |||||
| break; | |||||
| default: | default: | ||||
| throw new ClassFormatError("Invalid Constant Pool entry Type " | throw new ClassFormatError("Invalid Constant Pool entry Type " | ||||
| + cpTag); | + cpTag); | ||||
| @@ -0,0 +1,34 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.depend.constantpool; | |||||
| import java.io.DataInputStream; | |||||
| import java.io.IOException; | |||||
| /** | |||||
| * Represents the module info constant pool entry | |||||
| */ | |||||
| public class ModuleCPInfo extends ConstantCPInfo { | |||||
| private int moduleNameIndex; | |||||
| private String moduleName; | |||||
| public ModuleCPInfo() { | |||||
| super(CONSTANT_MODULEINFO, 1); | |||||
| } | |||||
| @Override | |||||
| public void read(final DataInputStream cpStream) throws IOException { | |||||
| this.moduleNameIndex = cpStream.readUnsignedShort(); | |||||
| } | |||||
| @Override | |||||
| public void resolve(final ConstantPool constantPool) { | |||||
| this.moduleName = ((Utf8CPInfo) constantPool.getEntry(this.moduleNameIndex)).getValue(); | |||||
| super.resolve(constantPool); | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return "Module info Constant Pool Entry for " + this.moduleName + "[" + this.moduleNameIndex + "]"; | |||||
| } | |||||
| } | |||||
| @@ -27,7 +27,9 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.FileUtilities; | import org.apache.tools.ant.FileUtilities; | ||||
| import org.apache.tools.ant.taskdefs.condition.JavaVersion; | |||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.junit.Assume; | |||||
| import org.junit.Before; | import org.junit.Before; | ||||
| import org.junit.Rule; | import org.junit.Rule; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| @@ -194,4 +196,16 @@ public class DependTest { | |||||
| .and(containsString("but has not been deleted because its source file could not be determined"))); | .and(containsString("but has not been deleted because its source file could not be determined"))); | ||||
| } | } | ||||
| /** | |||||
| * Tests that the depend task when run against a path containing a module-info.class (Java 9+ construct) | |||||
| * doesn't run into error | |||||
| */ | |||||
| @Test | |||||
| public void testModuleInfo() { | |||||
| final JavaVersion atLeastJava9 = new JavaVersion(); | |||||
| atLeastJava9.setAtLeast("9"); | |||||
| Assume.assumeTrue("Skipping test execution since Java version is lesser than 9", atLeastJava9.eval()); | |||||
| buildRule.executeTarget("testmoduleinfo"); | |||||
| } | |||||
| } | } | ||||