diff --git a/make/RunTests.gmk b/make/RunTests.gmk index aba7b3a78f6..62ad51cd1b6 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -602,7 +602,6 @@ define SetupRunMicroTestBody --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.instruction=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.java.lang.constant=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.components=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED diff --git a/make/test/BuildMicrobenchmark.gmk b/make/test/BuildMicrobenchmark.gmk index 1ae5e3c328b..e4d6ebc9a52 100644 --- a/make/test/BuildMicrobenchmark.gmk +++ b/make/test/BuildMicrobenchmark.gmk @@ -100,7 +100,6 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \ --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.instruction=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.java.lang.constant=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.components=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED \ --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index f1574988b6f..72f777ec6c1 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -57,7 +57,6 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ --add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.java.lang.constant=ALL-UNNAMED \ --add-exports java.base/jdk.internal.module=ALL-UNNAMED \ --enable-preview, \ )) diff --git a/src/java.base/share/classes/jdk/internal/classfile/Classfile.java b/src/java.base/share/classes/jdk/internal/classfile/Classfile.java index 5c8d7abaa35..45378797925 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Classfile.java +++ b/src/java.base/share/classes/jdk/internal/classfile/Classfile.java @@ -52,7 +52,7 @@ import jdk.internal.classfile.attribute.CharacterRangeInfo; import jdk.internal.classfile.attribute.LocalVariableInfo; import jdk.internal.classfile.attribute.LocalVariableTypeInfo; import jdk.internal.classfile.instruction.ExceptionCatch; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.PackageDesc; /** * Main entry points for parsing, transforming, and generating classfiles. diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleAttribute.java b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleAttribute.java index 71fb892005a..bc684d8632a 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleAttribute.java +++ b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleAttribute.java @@ -39,8 +39,8 @@ import java.util.Optional; import java.util.Set; import java.util.function.Consumer; import java.lang.reflect.AccessFlag; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; import jdk.internal.classfile.impl.ModuleAttributeBuilderImpl; import jdk.internal.classfile.impl.Util; diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleExportInfo.java b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleExportInfo.java index b85f0cdac34..88e5d9405bc 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleExportInfo.java +++ b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleExportInfo.java @@ -30,8 +30,8 @@ import java.util.Set; import jdk.internal.classfile.constantpool.ModuleEntry; import jdk.internal.classfile.constantpool.PackageEntry; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; import java.lang.reflect.AccessFlag; import jdk.internal.classfile.Classfile; @@ -133,7 +133,7 @@ public sealed interface ModuleExportInfo */ static ModuleExportInfo of(PackageDesc exports, int exportFlags, List exportsTo) { - return of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(exports.packageInternalName())), + return of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(exports.internalName())), exportFlags, Util.moduleEntryList(exportsTo)); } diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleHashInfo.java b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleHashInfo.java index a2e73c065e1..d2ed165552f 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleHashInfo.java +++ b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleHashInfo.java @@ -25,7 +25,7 @@ package jdk.internal.classfile.attribute; import jdk.internal.classfile.constantpool.ModuleEntry; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; +import java.lang.constant.ModuleDesc; import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.UnboundAttribute; @@ -60,6 +60,6 @@ public sealed interface ModuleHashInfo * @param hash the hash value */ static ModuleHashInfo of(ModuleDesc moduleDesc, byte[] hash) { - return new UnboundAttribute.UnboundModuleHashInfo(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(moduleDesc.moduleName())), hash); + return new UnboundAttribute.UnboundModuleHashInfo(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(moduleDesc.name())), hash); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleOpenInfo.java b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleOpenInfo.java index df14646f95c..1bca2056900 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleOpenInfo.java +++ b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleOpenInfo.java @@ -30,8 +30,8 @@ import java.util.Set; import jdk.internal.classfile.constantpool.ModuleEntry; import jdk.internal.classfile.constantpool.PackageEntry; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; import java.lang.reflect.AccessFlag; import jdk.internal.classfile.impl.TemporaryConstantPool; @@ -130,7 +130,7 @@ public sealed interface ModuleOpenInfo */ static ModuleOpenInfo of(PackageDesc opens, int opensFlags, List opensTo) { - return of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(opens.packageInternalName())), + return of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(opens.internalName())), opensFlags, Util.moduleEntryList(opensTo)); } diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModulePackagesAttribute.java b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModulePackagesAttribute.java index 464e2a6a532..f1851835ef9 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModulePackagesAttribute.java +++ b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModulePackagesAttribute.java @@ -32,7 +32,7 @@ import java.util.Arrays; import java.util.List; import jdk.internal.classfile.constantpool.PackageEntry; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.PackageDesc; import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.UnboundAttribute; @@ -75,7 +75,7 @@ public sealed interface ModulePackagesAttribute static ModulePackagesAttribute ofNames(List packages) { var p = new PackageEntry[packages.size()]; for (int i = 0; i < packages.size(); i++) { - p[i] = TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(packages.get(i).packageInternalName())); + p[i] = TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(packages.get(i).internalName())); } return of(p); } diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleRequireInfo.java b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleRequireInfo.java index e5b720a2df9..9c2481a89bb 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleRequireInfo.java +++ b/src/java.base/share/classes/jdk/internal/classfile/attribute/ModuleRequireInfo.java @@ -31,7 +31,7 @@ import java.util.Set; import jdk.internal.classfile.constantpool.ModuleEntry; import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.reflect.AccessFlag; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; +import java.lang.constant.ModuleDesc; import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.Util; @@ -100,7 +100,7 @@ public sealed interface ModuleRequireInfo * @param requiresVersion the required version */ static ModuleRequireInfo of(ModuleDesc requires, int requiresFlags, String requiresVersion) { - return new UnboundAttribute.UnboundModuleRequiresInfo(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(requires.moduleName())), requiresFlags, Optional.ofNullable(requiresVersion).map(s -> TemporaryConstantPool.INSTANCE.utf8Entry(s))); + return new UnboundAttribute.UnboundModuleRequiresInfo(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(requires.name())), requiresFlags, Optional.ofNullable(requiresVersion).map(s -> TemporaryConstantPool.INSTANCE.utf8Entry(s))); } /** diff --git a/src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPoolBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPoolBuilder.java index 0442b361291..df7a0d746e8 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPoolBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPoolBuilder.java @@ -40,8 +40,8 @@ import jdk.internal.classfile.ClassModel; import jdk.internal.classfile.Classfile; import jdk.internal.classfile.impl.ClassReaderImpl; import jdk.internal.classfile.impl.Options; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; import jdk.internal.classfile.WritableElement; import jdk.internal.classfile.impl.SplitConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool; @@ -185,7 +185,7 @@ public sealed interface ConstantPoolBuilder * @param packageDesc the symbolic descriptor for the class */ default PackageEntry packageEntry(PackageDesc packageDesc) { - return packageEntry(utf8Entry(packageDesc.packageInternalName())); + return packageEntry(utf8Entry(packageDesc.internalName())); } /** @@ -209,7 +209,7 @@ public sealed interface ConstantPoolBuilder * @param moduleDesc the symbolic descriptor for the class */ default ModuleEntry moduleEntry(ModuleDesc moduleDesc) { - return moduleEntry(utf8Entry(moduleDesc.moduleName())); + return moduleEntry(utf8Entry(moduleDesc.name())); } /** diff --git a/src/java.base/share/classes/jdk/internal/classfile/constantpool/ModuleEntry.java b/src/java.base/share/classes/jdk/internal/classfile/constantpool/ModuleEntry.java index 890ad9eb907..b2a57e1e0ad 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/constantpool/ModuleEntry.java +++ b/src/java.base/share/classes/jdk/internal/classfile/constantpool/ModuleEntry.java @@ -25,7 +25,7 @@ package jdk.internal.classfile.constantpool; import jdk.internal.classfile.impl.AbstractPoolEntry; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; +import java.lang.constant.ModuleDesc; /** * Models a {@code CONSTANT_Module_info} constant in the constant pool of a diff --git a/src/java.base/share/classes/jdk/internal/classfile/constantpool/PackageEntry.java b/src/java.base/share/classes/jdk/internal/classfile/constantpool/PackageEntry.java index 14354e11db7..201fa56558a 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/constantpool/PackageEntry.java +++ b/src/java.base/share/classes/jdk/internal/classfile/constantpool/PackageEntry.java @@ -25,7 +25,7 @@ package jdk.internal.classfile.constantpool; import jdk.internal.classfile.impl.AbstractPoolEntry; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.PackageDesc; /** * Models a {@code CONSTANT_Package_info} constant in the constant pool of a diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java index d2efb57ac5e..296f5bce833 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java @@ -51,8 +51,8 @@ import jdk.internal.classfile.constantpool.PackageEntry; import jdk.internal.classfile.constantpool.PoolEntry; import jdk.internal.classfile.constantpool.StringEntry; import jdk.internal.classfile.constantpool.Utf8Entry; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; public abstract sealed class AbstractPoolEntry { /* diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java index 4c1e88481c4..bbef9d31c7d 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java @@ -948,14 +948,14 @@ public final class ClassPrinterImpl { .map(Utf8Entry::stringValue).orElse(null))))), new ListNodeImpl(BLOCK, "exports", ma.exports().stream().map(exp -> new MapNodeImpl(FLOW, "exp").with( - leaf("package", exp.exportedPackage().asSymbol().packageName()), + leaf("package", exp.exportedPackage().asSymbol().name()), list("flags", "flag", exp.exportsFlags().stream() .map(AccessFlag::name)), list("to", "module", exp.exportsTo().stream() .map(me -> me.name().stringValue()))))), new ListNodeImpl(BLOCK, "opens", ma.opens().stream().map(opn -> new MapNodeImpl(FLOW, "opn").with( - leaf("package", opn.openedPackage().asSymbol().packageName()), + leaf("package", opn.openedPackage().asSymbol().name()), list("flags", "flag", opn.opensFlags().stream() .map(AccessFlag::name)), list("to", "module", opn.opensTo().stream() @@ -967,7 +967,7 @@ public final class ClassPrinterImpl { .map(ce -> ce.name().stringValue()))))))); case ModulePackagesAttribute mopa -> nodes.add(list("module packages", "subclass", mopa.packages().stream() - .map(mp -> mp.asSymbol().packageName()))); + .map(mp -> mp.asSymbol().name()))); case ModuleMainClassAttribute mmca -> nodes.add(leaf("module main class", mmca.mainClass().name().stringValue())); case RecordAttribute ra -> diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ModuleAttributeBuilderImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ModuleAttributeBuilderImpl.java index cefd201af66..6dfe155db53 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ModuleAttributeBuilderImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ModuleAttributeBuilderImpl.java @@ -30,8 +30,8 @@ import jdk.internal.classfile.attribute.ModuleAttribute.ModuleAttributeBuilder; import jdk.internal.classfile.constantpool.ClassEntry; import jdk.internal.classfile.constantpool.ModuleEntry; import jdk.internal.classfile.constantpool.Utf8Entry; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; import java.lang.constant.ClassDesc; import java.util.*; @@ -55,7 +55,7 @@ public final class ModuleAttributeBuilderImpl } public ModuleAttributeBuilderImpl(ModuleDesc moduleName) { - this(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(moduleName.moduleName()))); + this(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(moduleName.name()))); } @Override @@ -67,7 +67,7 @@ public final class ModuleAttributeBuilderImpl @Override public ModuleAttributeBuilder moduleName(ModuleDesc moduleName) { Objects.requireNonNull(moduleName); - moduleEntry = TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(moduleName.moduleName())); + moduleEntry = TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(moduleName.name())); return this; } @@ -86,7 +86,7 @@ public final class ModuleAttributeBuilderImpl @Override public ModuleAttributeBuilder requires(ModuleDesc module, int flags, String version) { Objects.requireNonNull(module); - return requires(ModuleRequireInfo.of(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(module.moduleName())), flags, version == null ? null : TemporaryConstantPool.INSTANCE.utf8Entry(version))); + return requires(ModuleRequireInfo.of(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(module.name())), flags, version == null ? null : TemporaryConstantPool.INSTANCE.utf8Entry(version))); } @Override @@ -101,8 +101,8 @@ public final class ModuleAttributeBuilderImpl Objects.requireNonNull(pkge); var exportsTo = new ArrayList(exportsToModules.length); for (var e : exportsToModules) - exportsTo.add(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(e.moduleName()))); - return exports(ModuleExportInfo.of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(pkge.packageInternalName())), flags, exportsTo)); + exportsTo.add(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(e.name()))); + return exports(ModuleExportInfo.of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(pkge.internalName())), flags, exportsTo)); } @Override @@ -117,8 +117,8 @@ public final class ModuleAttributeBuilderImpl Objects.requireNonNull(pkge); var opensTo = new ArrayList(opensToModules.length); for (var e : opensToModules) - opensTo.add(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(e.moduleName()))); - return opens(ModuleOpenInfo.of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(pkge.packageInternalName())), flags, opensTo)); + opensTo.add(TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(e.name()))); + return opens(ModuleOpenInfo.of(TemporaryConstantPool.INSTANCE.packageEntry(TemporaryConstantPool.INSTANCE.utf8Entry(pkge.internalName())), flags, opensTo)); } @Override diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ModuleDescImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ModuleDescImpl.java deleted file mode 100644 index eefbe926ebb..00000000000 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ModuleDescImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.classfile.impl; - -import jdk.internal.classfile.java.lang.constant.ModuleDesc; - -public record ModuleDescImpl(String moduleName) implements ModuleDesc { - - /** - * Validates the correctness of a module name. In particular checks for the presence of - * invalid characters in the name. - * - * {@jvms 4.2.3} Module and Package Names - * - * @param name the module name - * @return the module name passed if valid - * @throws IllegalArgumentException if the module name is invalid - */ - public static String validateModuleName(String name) { - for (int i=name.length() - 1; i >= 0; i--) { - char ch = name.charAt(i); - if ((ch >= '\u0000' && ch <= '\u001F') - || ((ch == '\\' || ch == ':' || ch =='@') && (i == 0 || name.charAt(--i) != '\\'))) - throw new IllegalArgumentException("Invalid module name: " + name); - } - return name; - } -} diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/PackageDescImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/PackageDescImpl.java deleted file mode 100644 index 336cd50af69..00000000000 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/PackageDescImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.classfile.impl; - -import jdk.internal.classfile.java.lang.constant.PackageDesc; - -public record PackageDescImpl(String packageInternalName) implements PackageDesc { - - /** - * Validates the correctness of a binary package name. In particular checks for the presence of - * invalid characters in the name. - * - * @param name the package name - * @return the package name passed if valid - * @throws IllegalArgumentException if the package name is invalid - */ - public static String validateBinaryPackageName(String name) { - for (int i=0; i moduleEntryList(List list) { var result = new Object[list.size()]; // null check for (int i = 0; i < result.length; i++) { - result[i] = TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(list.get(i).moduleName())); + result[i] = TemporaryConstantPool.INSTANCE.moduleEntry(TemporaryConstantPool.INSTANCE.utf8Entry(list.get(i).name())); } return SharedSecrets.getJavaUtilCollectionAccess().listFromTrustedArrayNullsAllowed(result); } diff --git a/src/java.base/share/classes/jdk/internal/classfile/java/lang/constant/ModuleDesc.java b/src/java.base/share/classes/jdk/internal/classfile/java/lang/constant/ModuleDesc.java deleted file mode 100644 index ffc2f00b1b1..00000000000 --- a/src/java.base/share/classes/jdk/internal/classfile/java/lang/constant/ModuleDesc.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.classfile.java.lang.constant; - -import static java.util.Objects.requireNonNull; -import jdk.internal.classfile.impl.ModuleDescImpl; -import static jdk.internal.classfile.impl.ModuleDescImpl.*; - -/** - * A nominal descriptor for a {@link Module} constant. - * - *

To create a {@linkplain ModuleDesc} for a module, use {@link #of}. - * - */ -public sealed interface ModuleDesc - permits ModuleDescImpl { - - /** - * Returns a {@linkplain ModuleDesc} for a module, - * given the name of the module. - *

- * {@jvms 4.2.3} Module names are not encoded in "internal form" like class and interface names, that is, - * the ASCII periods (.) that separate the identifiers in a module name are not replaced by ASCII forward slashes (/). - *

- * Module names may be drawn from the entire Unicode codespace, subject to the following constraints: - *

    - *
  • A module name must not contain any code point in the range '\u0000' to '\u001F' inclusive. - *
  • The ASCII backslash (\) is reserved for use as an escape character in module names. - * It must not appear in a module name unless it is followed by an ASCII backslash, an ASCII colon (:), or an ASCII at-sign (@). - * The ASCII character sequence \\ may be used to encode a backslash in a module name. - *
  • The ASCII colon (:) and at-sign (@) are reserved for future use in module names. - * They must not appear in module names unless they are escaped. - * The ASCII character sequences \: and \@ may be used to encode a colon and an at-sign in a module name. - *
- * @param name module name - * @return a {@linkplain ModuleDesc} describing the desired module - * @throws NullPointerException if the argument is {@code null} - * @throws IllegalArgumentException if the name string is not in the - * correct format - */ - static ModuleDesc of(String name) { - validateModuleName(requireNonNull(name)); - return new ModuleDescImpl(name); - } - - /** - * Returns the module name of this {@linkplain ModuleDesc}. - * - * @return the module name - */ - String moduleName(); - - /** - * Compare the specified object with this descriptor for equality. Returns - * {@code true} if and only if the specified object is also a - * {@linkplain ModuleDesc} and both describe the same module. - * - * @param o the other object - * @return whether this descriptor is equal to the other object - */ - @Override - boolean equals(Object o); -} diff --git a/src/java.base/share/classes/jdk/internal/classfile/java/lang/constant/PackageDesc.java b/src/java.base/share/classes/jdk/internal/classfile/java/lang/constant/PackageDesc.java deleted file mode 100644 index b9ef6905216..00000000000 --- a/src/java.base/share/classes/jdk/internal/classfile/java/lang/constant/PackageDesc.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.classfile.java.lang.constant; - -import static java.util.Objects.requireNonNull; -import jdk.internal.classfile.impl.PackageDescImpl; -import static jdk.internal.classfile.impl.PackageDescImpl.*; - -/** - * A nominal descriptor for a {@link Package} constant. - * - *

To create a {@linkplain PackageDesc} for a package, use {@link #of} or - * {@link #ofInternalName(String)}. - * - */ -public sealed interface PackageDesc - permits PackageDescImpl { - - /** - * Returns a {@linkplain PackageDesc} for a package, - * given the name of the package, such as {@code "java.lang"}. - *

- * {@jls 13.1} - * - * @param name the fully qualified (dot-separated) binary package name - * @return a {@linkplain PackageDesc} describing the desired package - * @throws NullPointerException if the argument is {@code null} - * @throws IllegalArgumentException if the name string is not in the - * correct format - */ - static PackageDesc of(String name) { - validateBinaryPackageName(requireNonNull(name)); - return new PackageDescImpl(binaryToInternal(name)); - } - - /** - * Returns a {@linkplain PackageDesc} for a package, - * given the name of the package in internal form, - * such as {@code "java/lang"}. - *

- * {@jvms 4.2.1} In this internal form, the ASCII periods (.) that normally separate the identifiers - * which make up the binary name are replaced by ASCII forward slashes (/). - * @param name the fully qualified class name, in internal (slash-separated) form - * @return a {@linkplain PackageDesc} describing the desired package - * @throws NullPointerException if the argument is {@code null} - * @throws IllegalArgumentException if the name string is not in the - * correct format - */ - static PackageDesc ofInternalName(String name) { - validateInternalPackageName(requireNonNull(name)); - return new PackageDescImpl(name); - } - - /** - * Returns the fully qualified (slash-separated) internal package name - * of this {@linkplain PackageDesc}. - * - * @return the package name, or the empty string for the - * default package - */ - String packageInternalName(); - - /** - * Returns the fully qualified (dot-separated) binary package name - * of this {@linkplain PackageDesc}. - * - * @return the package name, or the empty string for the - * default package - */ - default String packageName() { - return internalToBinary(packageInternalName()); - } - - /** - * Compare the specified object with this descriptor for equality. Returns - * {@code true} if and only if the specified object is also a - * {@linkplain PackageDesc} and both describe the same package. - * - * @param o the other object - * @return whether this descriptor is equal to the other object - */ - @Override - boolean equals(Object o); -} diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java b/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java index 8b4eef0f5f3..9992b4bf396 100644 --- a/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java +++ b/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java @@ -42,8 +42,8 @@ import jdk.internal.classfile.attribute.ModuleMainClassAttribute; import jdk.internal.classfile.attribute.ModulePackagesAttribute; import jdk.internal.classfile.attribute.ModuleResolutionAttribute; import jdk.internal.classfile.attribute.ModuleTargetAttribute; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; /** diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java index 432a326e35d..97891d408ef 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java @@ -38,7 +38,6 @@ import org.testng.annotations.Test; * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.misc * java.base/jdk.internal.module * java.compiler diff --git a/test/hotspot/jtreg/testlibrary/ctw/Makefile b/test/hotspot/jtreg/testlibrary/ctw/Makefile index 3eb68006595..8998765fe2a 100644 --- a/test/hotspot/jtreg/testlibrary/ctw/Makefile +++ b/test/hotspot/jtreg/testlibrary/ctw/Makefile @@ -57,7 +57,6 @@ EXPORTS=--add-exports java.base/jdk.internal.jimage=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.java.lang.constant=ALL-UNNAMED \ --add-exports java.base/jdk.internal.access=ALL-UNNAMED CTW_MAIN_CLASS = sun.hotspot.tools.ctw.CompileTheWorld diff --git a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java index 6268ad7ac52..7f335d15edd 100644 --- a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java +++ b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java @@ -29,7 +29,6 @@ * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.JarUtils diff --git a/test/jdk/java/lang/ModuleTests/AnnotationsTest.java b/test/jdk/java/lang/ModuleTests/AnnotationsTest.java index ff8b6927feb..724b757cf7b 100644 --- a/test/jdk/java/lang/ModuleTests/AnnotationsTest.java +++ b/test/jdk/java/lang/ModuleTests/AnnotationsTest.java @@ -55,7 +55,6 @@ import static org.testng.Assert.*; * java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/java/lang/module/ClassFileVersionsTest.java b/test/jdk/java/lang/module/ClassFileVersionsTest.java index 39f6f33f8da..b0830f02903 100644 --- a/test/jdk/java/lang/module/ClassFileVersionsTest.java +++ b/test/jdk/java/lang/module/ClassFileVersionsTest.java @@ -26,7 +26,6 @@ * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/java/lang/module/ConfigurationTest.java b/test/jdk/java/lang/module/ConfigurationTest.java index f15b53a12b3..7bcd527c9cc 100644 --- a/test/jdk/java/lang/module/ConfigurationTest.java +++ b/test/jdk/java/lang/module/ConfigurationTest.java @@ -27,7 +27,6 @@ * java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build ConfigurationTest diff --git a/test/jdk/java/lang/module/ModuleDescriptorTest.java b/test/jdk/java/lang/module/ModuleDescriptorTest.java index 6ff5bb5443c..17ce09f6c0c 100644 --- a/test/jdk/java/lang/module/ModuleDescriptorTest.java +++ b/test/jdk/java/lang/module/ModuleDescriptorTest.java @@ -28,7 +28,6 @@ * java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.ModuleInfoWriter @@ -65,8 +64,8 @@ import jdk.internal.access.JavaLangModuleAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.classfile.Classfile; import jdk.internal.classfile.attribute.ModuleAttribute; -import jdk.internal.classfile.java.lang.constant.PackageDesc; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; import jdk.test.lib.util.ModuleInfoWriter; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/test/jdk/java/lang/module/ModuleFinderTest.java b/test/jdk/java/lang/module/ModuleFinderTest.java index 61db59b970c..42223227c9b 100644 --- a/test/jdk/java/lang/module/ModuleFinderTest.java +++ b/test/jdk/java/lang/module/ModuleFinderTest.java @@ -26,7 +26,6 @@ * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build ModuleFinderTest jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/java/lang/module/ModuleNamesTest.java b/test/jdk/java/lang/module/ModuleNamesTest.java index 8b69bf856ae..cacaa5c0f83 100644 --- a/test/jdk/java/lang/module/ModuleNamesTest.java +++ b/test/jdk/java/lang/module/ModuleNamesTest.java @@ -27,7 +27,6 @@ * java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/java/lang/module/MultiReleaseJarTest.java b/test/jdk/java/lang/module/MultiReleaseJarTest.java index db93cb17a77..2bc11729938 100644 --- a/test/jdk/java/lang/module/MultiReleaseJarTest.java +++ b/test/jdk/java/lang/module/MultiReleaseJarTest.java @@ -26,7 +26,6 @@ * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build MultiReleaseJarTest diff --git a/test/jdk/java/security/Provider/SecurityProviderModularTest.java b/test/jdk/java/security/Provider/SecurityProviderModularTest.java index d1133e95cc1..a919f104817 100644 --- a/test/jdk/java/security/Provider/SecurityProviderModularTest.java +++ b/test/jdk/java/security/Provider/SecurityProviderModularTest.java @@ -50,7 +50,6 @@ import jdk.test.lib.util.ModuleInfoWriter; * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.JarUtils diff --git a/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java b/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java index 28b03aeb8aa..5e90ecf839c 100644 --- a/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java +++ b/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java @@ -46,7 +46,6 @@ import jdk.test.lib.util.ModuleInfoWriter; * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.JarUtils jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java b/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java index 6e74558b905..9f808b2caad 100644 --- a/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java +++ b/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java @@ -45,7 +45,6 @@ import jdk.test.lib.util.ModuleInfoWriter; * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build jdk.test.lib.util.JarUtils jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/jdk/classfile/AdvancedTransformationsTest.java b/test/jdk/jdk/classfile/AdvancedTransformationsTest.java index c4cce557e55..e809d40933c 100644 --- a/test/jdk/jdk/classfile/AdvancedTransformationsTest.java +++ b/test/jdk/jdk/classfile/AdvancedTransformationsTest.java @@ -61,7 +61,7 @@ import jdk.internal.classfile.instruction.ReturnInstruction; import jdk.internal.classfile.instruction.StoreInstruction; import java.lang.reflect.AccessFlag; import jdk.internal.classfile.components.CodeRelabeler; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; +import java.lang.constant.ModuleDesc; import jdk.internal.classfile.components.ClassPrinter; import static java.lang.annotation.ElementType.*; import java.lang.annotation.Retention; diff --git a/test/jdk/jdk/classfile/ModuleBuilderTest.java b/test/jdk/jdk/classfile/ModuleBuilderTest.java index 4b3e6a285ea..03845db3221 100644 --- a/test/jdk/jdk/classfile/ModuleBuilderTest.java +++ b/test/jdk/jdk/classfile/ModuleBuilderTest.java @@ -38,8 +38,8 @@ import jdk.internal.classfile.attribute.ModulePackagesAttribute; import jdk.internal.classfile.attribute.ModuleProvideInfo; import jdk.internal.classfile.attribute.ModuleRequireInfo; import jdk.internal.classfile.Attributes; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; import org.junit.jupiter.api.Test; import java.lang.constant.ClassDesc; @@ -104,7 +104,7 @@ class ModuleBuilderTest { var cm = Classfile.parse(modBytes); var attr =cm.findAttribute(Attributes.MODULE).get(); - assertEquals(attr.moduleName().name().stringValue(), modName.moduleName()); + assertEquals(attr.moduleName().name().stringValue(), modName.name()); assertEquals(attr.moduleFlagsMask(), 0); assertEquals(attr.moduleVersion().get().stringValue(), modVsn); } @@ -118,12 +118,12 @@ class ModuleBuilderTest { void testVerifyRequires() { assertEquals(attr.requires().size(), 2); ModuleRequireInfo r = attr.requires().get(0); - assertEquals(r.requires().name().stringValue(), require1.moduleName()); + assertEquals(r.requires().name().stringValue(), require1.name()); assertEquals(r.requiresVersion().get().stringValue(), vsn1); assertEquals(r.requiresFlagsMask(), 77); r = attr.requires().get(1); - assertEquals(r.requires().name().stringValue(), require2.moduleName()); + assertEquals(r.requires().name().stringValue(), require2.name()); assertEquals(r.requiresVersion().get().stringValue(), vsn2); assertEquals(r.requiresFlagsMask(), 99); } @@ -138,14 +138,14 @@ class ModuleBuilderTest { } assertEquals(exports.get(0).exportsTo().size(), 2); for (int i = 0; i < 2; i++) - assertEquals(exports.get(0).exportsTo().get(i).name().stringValue(), et1[i].moduleName()); + assertEquals(exports.get(0).exportsTo().get(i).name().stringValue(), et1[i].name()); assertEquals(exports.get(1).exportsTo().size(), 1); - assertEquals(exports.get(1).exportsTo().get(0).name().stringValue(), et2[0].moduleName()); + assertEquals(exports.get(1).exportsTo().get(0).name().stringValue(), et2[0].name()); assertEquals(exports.get(2).exportsTo().size(), 3); for (int i = 0; i < 3; i++) - assertEquals(exports.get(2).exportsTo().get(i).name().stringValue(), et3[i].moduleName()); + assertEquals(exports.get(2).exportsTo().get(i).name().stringValue(), et3[i].name()); assertEquals(exports.get(3).exportsTo().size(), 0); assertEquals(exports.get(4).exportsTo().size(), 0); @@ -159,7 +159,7 @@ class ModuleBuilderTest { assertEquals(opens.get(1).opensTo().size(), 0); assertEquals(opens.get(2).opensTo().size(), 2); assertEquals(opens.get(2).opensFlagsMask(), 2); - assertEquals(opens.get(2).opensTo().get(1).name().stringValue(), ot3[1].moduleName()); + assertEquals(opens.get(2).opensTo().get(1).name().stringValue(), ot3[1].name()); } @Test @@ -182,7 +182,7 @@ class ModuleBuilderTest { @Test void verifyPackages() { ModulePackagesAttribute a = moduleModel.findAttribute(Attributes.MODULE_PACKAGES).orElseThrow(); - assertEquals(a.packages().stream().map(pe -> pe.asSymbol().packageName()).toList(), List.of("foo.bar.baz", "quux")); + assertEquals(a.packages().stream().map(pe -> pe.asSymbol().name()).toList(), List.of("foo.bar.baz", "quux")); } @Test diff --git a/test/jdk/jdk/classfile/ModuleDescTest.java b/test/jdk/jdk/classfile/ModuleDescTest.java deleted file mode 100644 index bbf0fffddc6..00000000000 --- a/test/jdk/jdk/classfile/ModuleDescTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Testing ModuleDesc. - * @run junit ModuleDescTest - */ -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import static org.junit.jupiter.api.Assertions.*; - -class ModuleDescTest { - - @ParameterizedTest - @ValueSource(strings = {"abc\\", "ab\\c", "\u0000", "\u0001", "\u001e", "\u001f"}) - public void testInvalidModuleNames(String mdl) { - assertThrows(IllegalArgumentException.class, () -> ModuleDesc.of(mdl)); - } - - @ParameterizedTest - @ValueSource(strings = {"a\\\\b", "a.b/c", "a\\@b\\: c"}) - public void testValidModuleNames(String mdl) { - assertEquals(ModuleDesc.of(mdl), ModuleDesc.of(mdl)); - assertEquals(ModuleDesc.of(mdl).moduleName(), mdl); - } -} diff --git a/test/jdk/jdk/classfile/PackageDescTest.java b/test/jdk/jdk/classfile/PackageDescTest.java deleted file mode 100644 index 3d52a2153f1..00000000000 --- a/test/jdk/jdk/classfile/PackageDescTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Testing PackageDesc. - * @run junit PackageDescTest - */ -import jdk.internal.classfile.java.lang.constant.PackageDesc; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -class PackageDescTest { - @ParameterizedTest - @ValueSource(strings = {"a/b.d", "a[]", "a;"}) - void testInvalidPackageNames(String pkg) { - assertThrows(IllegalArgumentException.class, () -> PackageDesc.of(pkg)); - } - - @ParameterizedTest - @ValueSource(strings = {"a/b.d", "a[]", "a;"}) - void testInvalidInternalPackageNames(String pkg) { - assertThrows(IllegalArgumentException.class, () -> PackageDesc.ofInternalName(pkg)); - } - - @Test - void testValidPackageNames() { - assertEquals(PackageDesc.of("a"), PackageDesc.ofInternalName("a")); - assertEquals(PackageDesc.of("a.b"), PackageDesc.ofInternalName("a/b")); - assertEquals(PackageDesc.of("a.b.c"), PackageDesc.ofInternalName("a/b/c")); - assertEquals(PackageDesc.of("a").packageName(), PackageDesc.ofInternalName("a").packageName()); - assertEquals(PackageDesc.of("a.b").packageName(), PackageDesc.ofInternalName("a/b").packageName()); - assertEquals(PackageDesc.of("a.b.c").packageName(), PackageDesc.ofInternalName("a/b/c").packageName()); - assertEquals(PackageDesc.of("a").packageInternalName(), PackageDesc.ofInternalName("a").packageInternalName()); - assertEquals(PackageDesc.of("a.b").packageInternalName(), PackageDesc.ofInternalName("a/b").packageInternalName()); - assertEquals(PackageDesc.of("a.b.c").packageInternalName(), PackageDesc.ofInternalName("a/b/c").packageInternalName()); - } -} diff --git a/test/jdk/jdk/classfile/TEST.properties b/test/jdk/jdk/classfile/TEST.properties index 41aaa61dc62..edd759404a0 100644 --- a/test/jdk/jdk/classfile/TEST.properties +++ b/test/jdk/jdk/classfile/TEST.properties @@ -7,7 +7,6 @@ modules = \ java.base/jdk.internal.classfile.instruction \ java.base/jdk.internal.classfile.impl \ java.base/jdk.internal.classfile.impl.verifier \ - java.base/jdk.internal.classfile.java.lang.constant \ java.base/jdk.internal.classfile.components \ java.base/jdk.internal.classfile.util \ java.base/jdk.internal.org.objectweb.asm \ diff --git a/test/jdk/jdk/classfile/examples/ModuleExamples.java b/test/jdk/jdk/classfile/examples/ModuleExamples.java index 5ffdbb51bfa..8b97b7f8770 100644 --- a/test/jdk/jdk/classfile/examples/ModuleExamples.java +++ b/test/jdk/jdk/classfile/examples/ModuleExamples.java @@ -46,8 +46,8 @@ import jdk.internal.classfile.attribute.ModuleMainClassAttribute; import jdk.internal.classfile.attribute.ModulePackagesAttribute; import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import jdk.internal.classfile.Attributes; -import jdk.internal.classfile.java.lang.constant.PackageDesc; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; public class ModuleExamples { private static final FileSystem JRT = FileSystems.getFileSystem(URI.create("jrt:/")); diff --git a/test/jdk/jdk/classfile/helpers/RebuildingTransformation.java b/test/jdk/jdk/classfile/helpers/RebuildingTransformation.java index f2441f86fc3..0c21d17b9c9 100644 --- a/test/jdk/jdk/classfile/helpers/RebuildingTransformation.java +++ b/test/jdk/jdk/classfile/helpers/RebuildingTransformation.java @@ -32,8 +32,8 @@ import jdk.internal.classfile.*; import jdk.internal.classfile.attribute.*; import jdk.internal.classfile.constantpool.*; import jdk.internal.classfile.instruction.*; -import jdk.internal.classfile.java.lang.constant.ModuleDesc; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.ModuleDesc; +import java.lang.constant.PackageDesc; import jdk.internal.classfile.components.CodeStackTracker; class RebuildingTransformation { diff --git a/test/jdk/jdk/modules/incubator/ServiceBinding.java b/test/jdk/jdk/modules/incubator/ServiceBinding.java index 81d7aa2a2c1..521dcb5f158 100644 --- a/test/jdk/jdk/modules/incubator/ServiceBinding.java +++ b/test/jdk/jdk/modules/incubator/ServiceBinding.java @@ -27,7 +27,6 @@ * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build ServiceBinding TestBootLayer jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/sun/tools/jcmd/TestProcessHelper.java b/test/jdk/sun/tools/jcmd/TestProcessHelper.java index 7864378f94e..121591fce21 100644 --- a/test/jdk/sun/tools/jcmd/TestProcessHelper.java +++ b/test/jdk/sun/tools/jcmd/TestProcessHelper.java @@ -57,7 +57,6 @@ import jdk.test.lib.util.ModuleInfoWriter; * java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.module * @library /test/lib * @build test.TestProcess diff --git a/test/jdk/tools/jlink/JLinkNegativeTest.java b/test/jdk/tools/jlink/JLinkNegativeTest.java index 03db28bf6a8..edfdfbb43ea 100644 --- a/test/jdk/tools/jlink/JLinkNegativeTest.java +++ b/test/jdk/tools/jlink/JLinkNegativeTest.java @@ -31,7 +31,6 @@ * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool - * java.base/jdk.internal.classfile.java.lang.constant * java.base/jdk.internal.jimage * java.base/jdk.internal.module * jdk.jdeps/com.sun.tools.classfile diff --git a/test/lib/jdk/test/lib/util/ModuleInfoWriter.java b/test/lib/jdk/test/lib/util/ModuleInfoWriter.java index 8aae7654fb7..91a96334371 100644 --- a/test/lib/jdk/test/lib/util/ModuleInfoWriter.java +++ b/test/lib/jdk/test/lib/util/ModuleInfoWriter.java @@ -31,7 +31,7 @@ import java.lang.reflect.AccessFlag; import java.nio.ByteBuffer; import java.util.Map; import jdk.internal.classfile.Classfile; -import jdk.internal.classfile.java.lang.constant.PackageDesc; +import java.lang.constant.PackageDesc; import jdk.internal.classfile.attribute.ModuleAttribute; import jdk.internal.classfile.attribute.ModuleExportInfo; import jdk.internal.classfile.attribute.ModuleMainClassAttribute;