*
- * When resource bundles are deployed in named modules, the following
- * module-specific requirements and restrictions are applied.
+ * Resource bundles can be deployed in modules in the following ways:
*
- *
- *
Code in a named module that calls {@link #getBundle(String, Locale)}
- * will locate resource bundles in the caller's module (caller module).
- *
If resource bundles are deployed in named modules separate from
- * the caller module, those resource bundles need to be loaded from service
- * providers of {@link ResourceBundleProvider}. The caller module must declare
- * "{@code uses}" and the service interface name is the concatenation of the
- * package name of the base name, string "{@code .spi.}", the simple class
- * name of the base name, and the string "{@code Provider}". The
- * bundle provider modules containing resource bundles must
- * declare "{@code provides}" with the service interface name and
- * its implementation class name. For example, if the base name is
- * "{@code com.example.app.MyResources}", the caller module must declare
- * "{@code uses com.example.app.spi.MyResourcesProvider;}" and a module containing resource
- * bundles must declare "{@code provides com.example.app.spi.MyResourcesProvider
- * with com.example.app.internal.MyResourcesProviderImpl;}"
- * where {@code com.example.app.internal.MyResourcesProviderImpl} is an
- * implementation class of {@code com.example.app.spi.MyResourcesProvider}.
- *
If you want to use non-standard formats in named modules, such as XML,
- * {@link ResourceBundleProvider} needs to be used.
- *
The {@code getBundle} method with a {@code ClassLoader} may not be able to
- * find resource bundles using the given {@code ClassLoader} in named modules.
- * The {@code getBundle} method with a {@code Module} can be used, instead.
- *
{@code ResourceBundle.Control} is not supported in named modules.
- * If the {@code getBundle} method with a {@code ResourceBundle.Control} is called
- * in a named module, the method will throw an {@code UnsupportedOperationException}.
- * Any service providers of {@link ResourceBundleControlProvider} are ignored in
- * named modules.
- *
+ * Resource bundles can be deployed together with an application in the same
+ * module. In that case, the resource bundles are loaded
+ * by code in the module by calling the {@link #getBundle(String)}
+ * or {@link #getBundle(String, Locale)} method.
*
- * The {@code getBundle} factory methods load service providers of
- * {@link ResourceBundleProvider}, if available, using {@link ServiceLoader}.
- * The service type is designated by
- * {@code + ".spi." + + "Provider"}. For
- * example, if the base name is "{@code com.example.app.MyResources}", the service
- * type is {@code com.example.app.spi.MyResourcesProvider}.
- *
- * In named modules, the loaded service providers for the given base name are
- * used to load resource bundles. If no service provider is available, or if
- * none of the service providers returns a resource bundle and the caller module
- * doesn't have its own service provider, the {@code getBundle} factory method
- * searches for resource bundles that are local in the caller module and that
- * are visible to the class loader of the caller module. The resource bundle
- * formats for local module searching are "java.class" and "java.properties".
+ *
+ *
+ * Resource bundles can be deployed in one or more service provider modules
+ * and they can be located using {@link ServiceLoader}.
+ * A {@linkplain ResourceBundleProvider service} interface or class must be
+ * defined. The caller module declares that it uses the service, the service
+ * provider modules declare that they provide implementations of the service.
+ * Refer to {@link ResourceBundleProvider} for developing resource bundle
+ * services and deploying resource bundle providers.
+ * The module obtaining the resource bundle can be a resource bundle
+ * provider itself; in which case this module only locates the resource bundle
+ * via service provider mechanism.
+ *
+ *
A {@linkplain ResourceBundleProvider resource bundle provider} can
+ * provide resource bundles in any format such XML which replaces the need
+ * of {@link Control ResourceBundle.Control}.
+ *
+ *
+ *
+ * Resource bundles in a named module may be encapsulated so that
+ * it cannot be located by code in other modules. Resource bundles
+ * in unnamed modules and class path are open for any module to access.
+ * Resource bundle follows the resource encapsulation rules as specified
+ * in {@link Module#getResourceAsStream(String)}.
+ *
+ *
The {@code getBundle} factory methods with no {@code Control} parameter
+ * locate and load resource bundles from
+ * {@linkplain ResourceBundleProvider service providers}.
+ * It may continue the search as if calling {@link Module#getResourceAsStream(String)}
+ * to find the named resource from a given module and calling
+ * {@link ClassLoader#getResourceAsStream(String)}; refer to
+ * the specification of the {@code getBundle} method for details.
+ * Only non-encapsulated resource bundles of "{@code java.class}"
+ * or "{@code java.properties}" format are searched.
+ *
+ *
If the caller module is a
+ *
+ * resource bundle provider, it does not fall back to the
+ * class loader search.
+ *
+ *
Resource bundles in automatic modules
+ *
+ * A common format of resource bundles is in {@linkplain PropertyResourceBundle
+ * .properties} file format. Typically {@code .properties} resource bundles
+ * are packaged in a JAR file. Resource bundle only JAR file can be readily
+ * deployed as an
+ * automatic module. For example, if the JAR file contains the
+ * entry "{@code p/q/Foo_ja.properties}" and no {@code .class} entry,
+ * when resolved and defined as an automatic module, no package is derived
+ * for this module. This allows resource bundles in {@code .properties}
+ * format packaged in one or more JAR files that may contain entries
+ * in the same directory and can be resolved successfully as
+ * automatic modules.
*
*
{@link ResourceBundle.Control} is designed for an application deployed
+ * in an unnamed module, for example to support resource bundles in
+ * non-standard formats or package localized resources in a non-traditional
+ * convention. {@link ResourceBundleProvider} is the replacement for
+ * {@code ResourceBundle.Control} when migrating to modules.
+ * {@code UnsupportedOperationException} will be thrown when a factory
+ * method that takes the {@code ResourceBundle.Control} parameter is called.
+ *
*
For the {@code getBundle} factory
* methods that take no {@link Control} instance, their default behavior of resource bundle loading
@@ -815,14 +835,10 @@ public abstract class ResourceBundle {
/**
* Gets a resource bundle using the specified base name, the default locale,
- * and the caller's class loader. Calling this method is equivalent to calling
+ * and the caller module. Calling this method is equivalent to calling
*
- * except that getClassLoader() is run with the security
- * privileges of ResourceBundle.
- * See {@link #getBundle(String, Locale, ClassLoader) getBundle}
- * for a complete description of the search and instantiation strategy.
*
* @param baseName the base name of the resource bundle, a fully qualified class name
* @exception java.lang.NullPointerException
@@ -830,6 +846,9 @@ public abstract class ResourceBundle {
* @exception MissingResourceException
* if no resource bundle for the specified base name can be found
* @return a resource bundle for the given base name and the default locale
+ *
+ * @see Resource Bundle Search and Loading Strategy
+ * @see Resource Bundles and Named Modules
*/
@CallerSensitive
public static final ResourceBundle getBundle(String baseName)
@@ -887,14 +906,10 @@ public abstract class ResourceBundle {
/**
* Gets a resource bundle using the specified base name and locale,
- * and the caller's class loader. Calling this method is equivalent to calling
+ * and the caller module. Calling this method is equivalent to calling
*
- * except that getClassLoader() is run with the security
- * privileges of ResourceBundle.
- * See {@link #getBundle(String, Locale, ClassLoader) getBundle}
- * for a complete description of the search and instantiation strategy.
*
* @param baseName
* the base name of the resource bundle, a fully qualified class name
@@ -905,6 +920,9 @@ public abstract class ResourceBundle {
* @exception MissingResourceException
* if no resource bundle for the specified base name can be found
* @return a resource bundle for the given base name and locale
+ *
+ * @see Resource Bundle Search and Loading Strategy
+ * @see Resource Bundles and Named Modules
*/
@CallerSensitive
public static final ResourceBundle getBundle(String baseName,
@@ -922,19 +940,6 @@ public abstract class ResourceBundle {
* getBundle(baseName, Locale.getDefault(), module)
*
*
- *
Resource bundles in named modules may be encapsulated. When
- * the resource bundle is loaded from a provider, the caller module
- * must have an appropriate uses clause in its module descriptor
- * to declare that the module uses implementations of
- * {@code + ".spi." + + "Provider"}.
- * Otherwise, it will load the resource bundles that are local in the
- * given module or that are visible to the class loader of the given module
- * (refer to the Resource Bundles in Named Modules
- * section for details).
- * When the resource bundle is loaded from the specified module, it is
- * subject to the encapsulation rules specified by
- * {@link Module#getResourceAsStream Module.getResourceAsStream}.
- *
* @param baseName the base name of the resource bundle,
* a fully qualified class name
* @param module the module for which the resource bundle is searched
@@ -950,6 +955,8 @@ public abstract class ResourceBundle {
* @since 9
* @spec JPMS
* @see ResourceBundleProvider
+ * @see Resource Bundle Search and Loading Strategy
+ * @see Resource Bundles and Named Modules
*/
@CallerSensitive
public static ResourceBundle getBundle(String baseName, Module module) {
@@ -963,14 +970,15 @@ public abstract class ResourceBundle {
* on behalf of the specified module.
*
*
Resource bundles in named modules may be encapsulated. When
- * the resource bundle is loaded from a provider, the caller module
+ * the resource bundle is loaded from a
+ * {@linkplain ResourceBundleProvider service provider}, the caller module
* must have an appropriate uses clause in its module descriptor
- * to declare that the module uses implementations of
- * {@code + ".spi." + + "Provider"}.
+ * to declare that the module uses of {@link ResourceBundleProvider}
+ * for the named resource bundle.
* Otherwise, it will load the resource bundles that are local in the
- * given module or that are visible to the class loader of the given module
- * (refer to the Resource Bundles in Named Modules
- * section for details).
+ * given module as if calling {@link Module#getResourceAsStream(String)}
+ * or that are visible to the class loader of the given module
+ * as if calling {@link ClassLoader#getResourceAsStream(String)}.
* When the resource bundle is loaded from the specified module, it is
* subject to the encapsulation rules specified by
* {@link Module#getResourceAsStream Module.getResourceAsStream}.
@@ -1000,6 +1008,8 @@ public abstract class ResourceBundle {
* @return a resource bundle for the given base name and locale in the module
* @since 9
* @spec JPMS
+ * @see Resource Bundle Search and Loading Strategy
+ * @see Resource Bundles and Named Modules
*/
@CallerSensitive
public static ResourceBundle getBundle(String baseName, Locale targetLocale, Module module) {
@@ -1060,28 +1070,25 @@ public abstract class ResourceBundle {
* Gets a resource bundle using the specified base name, locale, and class
* loader.
*
- *
This method behaves the same as calling
- * {@link #getBundle(String, Locale, ClassLoader, Control)} passing a
- * default instance of {@link Control} unless another {@link Control} is
- * provided with the {@link ResourceBundleControlProvider} SPI. Refer to the
- * description of modifying the default
- * behavior.
+ *
When this method is called from a named module and the given
+ * loader is the class loader of the caller module, this is equivalent
+ * to calling:
+ *
+ * where {@code control} is the default instance of {@link Control} unless
+ * a {@code Control} instance is provided by
+ * {@link ResourceBundleControlProvider} SPI. Refer to the
+ * description of modifying the default
+ * behavior. The following describes the default behavior.
*
*
- * Resource bundles in a named module are private to that module. If
- * the caller is in a named module, this method will find resource bundles
- * from the service providers of {@link java.util.spi.ResourceBundleProvider}
- * if any. Otherwise, it will load the resource bundles that are visible to
- * the given {@code loader} (refer to the
- * Resource Bundles in Named Modules section
- * for details).
- * If the caller is in a named module and the given {@code loader} is
- * different than the caller's class loader, or if the caller is not in
- * a named module, this method will not find resource bundles from named
- * modules.
+ * Resource Bundle Search and Loading Strategy
*
*
getBundle uses the base name, the specified locale, and
* the default locale (obtained from {@link java.util.Locale#getDefault()
@@ -1201,7 +1208,7 @@ public abstract class ResourceBundle {
*
*
Note:The baseName argument should be a fully
* qualified class name. However, for compatibility with earlier versions,
- * Sun's Java SE Runtime Environments do not verify this, and so it is
+ * Java SE Runtime Environments do not verify this, and so it is
* possible to access PropertyResourceBundles by specifying a
* path name (using "/") instead of a fully qualified class name (using
* ".").
@@ -1248,7 +1255,7 @@ public abstract class ResourceBundle {
*
* @apiNote If the caller module is a named module and the given
* {@code loader} is the caller module's class loader, this method is
- * equivalent to {@code getBundle(baseName, locale)}; otherwise, it will not
+ * equivalent to {@code getBundle(baseName, locale)}; otherwise, it may not
* find resource bundles from named modules.
* Use {@link #getBundle(String, Locale, Module)} to load resource bundles
* on behalf on a specific module instead.
@@ -1264,6 +1271,7 @@ public abstract class ResourceBundle {
* @since 1.2
* @revised 9
* @spec JPMS
+ * @see Resource Bundles and Named Modules
*/
@CallerSensitive
public static ResourceBundle getBundle(String baseName, Locale locale,
@@ -1278,9 +1286,9 @@ public abstract class ResourceBundle {
/**
* Returns a resource bundle using the specified base name, target
- * locale, class loader and control. Unlike the {@linkplain
- * #getBundle(String, Locale, ClassLoader) getBundle
- * factory methods with no control argument}, the given
+ * locale, class loader and control. Unlike the {@link
+ * #getBundle(String, Locale, ClassLoader) getBundle}
+ * factory methods with no {@code control} argument, the given
* control specifies how to locate and instantiate resource
* bundles. Conceptually, the bundle loading process with the given
* control is performed in the following steps.
@@ -2365,7 +2373,14 @@ public abstract class ResourceBundle {
* the callback methods provides the information necessary for the
* factory methods to perform the default behavior.
- * Note that this class is not supported in named modules.
+ *
+ *
{@link ResourceBundle.Control} is designed for an application deployed
+ * in an unnamed module, for example to support resource bundles in
+ * non-standard formats or package localized resources in a non-traditional
+ * convention. {@link ResourceBundleProvider} is the replacement for
+ * {@code ResourceBundle.Control} when migrating to modules.
+ * {@code UnsupportedOperationException} will be thrown when a factory
+ * method that takes the {@code ResourceBundle.Control} parameter is called.
*
*
In addition to the callback methods, the {@link
* #toBundleName(String, Locale) toBundleName} and {@link
@@ -2501,8 +2516,8 @@ public abstract class ResourceBundle {
* }
*
*
- * @apiNote {@code ResourceBundle.Control} is not supported
- * in named modules. If the {@code ResourceBundle.getBundle} method with
+ * @apiNote {@code ResourceBundle.Control} is not supported
+ * in named modules. If the {@code ResourceBundle.getBundle} method with
* a {@code ResourceBundle.Control} is called in a named module, the method
* will throw an {@link UnsupportedOperationException}. Any service providers
* of {@link ResourceBundleControlProvider} are ignored in named modules.
diff --git a/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java b/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java
index 937d233e267..2c543c63bcf 100644
--- a/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java
+++ b/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java
@@ -45,42 +45,46 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
*
*
* Resource bundles can be packaged in one or more
- * named modules, bundle modules. The consumer of the
+ * named modules, service provider modules. The consumer of the
* resource bundle is the one calling {@link ResourceBundle#getBundle(String)}.
* In order for the consumer module to load a resource bundle
* "{@code com.example.app.MyResources}" provided by another module,
* it will use the {@linkplain java.util.ServiceLoader service loader}
- * mechanism. A service interface named "{@code com.example.app.MyResourcesProvider}"
- * must be defined and a bundle provider module will provide an
- * implementation class of "{@code com.example.app.MyResourcesProvider}"
+ * mechanism. A service interface named "{@code com.example.app.spi.MyResourcesProvider}"
+ * must be defined and a service provider module will provide an
+ * implementation class of "{@code com.example.app.spi.MyResourcesProvider}"
* as follows:
*
- *
+ * {@code import com.example.app.spi.MyResourcesProvider;
* class MyResourcesProviderImpl extends AbstractResourceBundleProvider
* implements MyResourcesProvider
* {
+ * public MyResourcesProviderImpl() {
+ * super("java.properties");
+ * }
+ * // this provider maps the resource bundle to per-language package
* protected String toBundleName(String baseName, Locale locale) {
- * // return the bundle name per the naming of the resource bundle
- * :
+ * return "p." + locale.getLanguage() + "." + baseName;
* }
*
* public ResourceBundle getBundle(String baseName, Locale locale) {
- * // this module only provides bundles in french
+ * // this module only provides bundles in French
* if (locale.equals(Locale.FRENCH)) {
* return super.getBundle(baseName, locale);
* }
+ * // otherwise return null
* return null;
* }
- * }
+ * }}
*
- * @see
- * Resource Bundles in Named Modules
- * @see
- * ResourceBundleProvider Service Providers
+ * Refer to {@link ResourceBundleProvider} for details.
*
+ * @see
+ * Resource Bundles and Named Modules
* @since 9
* @spec JPMS
+
*/
public abstract class AbstractResourceBundleProvider implements ResourceBundleProvider {
private static final JavaUtilResourceBundleAccess RB_ACCESS =
diff --git a/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java b/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java
index 0cb0bccd4a6..62fa501c538 100644
--- a/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java
+++ b/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java
@@ -29,33 +29,117 @@ import java.util.Locale;
import java.util.ResourceBundle;
/**
- * {@code ResourceBundleProvider} is a provider interface that is used for
- * loading resource bundles for named modules. Implementation classes of
- * this interface are loaded with {@link java.util.ServiceLoader ServiceLoader}
- * during a call to the
- * {@link ResourceBundle#getBundle(String, Locale, ClassLoader)
- * ResourceBundle.getBundle} method. The provider service type is determined by
- * {@code + ".spi." + + "Provider"}.
+ * {@code ResourceBundleProvider} is a service provider interface for
+ * resource bundles. It is used by
+ * {@link ResourceBundle#getBundle(String) ResourceBundle.getBundle}
+ * factory methods to locate and load the service providers that are deployed as
+ * modules via {@link java.util.ServiceLoader ServiceLoader}.
*
- *
- * For example, if the base name is "com.example.app.MyResources",
- * {@code com.example.app.spi.MyResourcesProvider} will be the provider service type:
- *
{@code
+ *
Developing resource bundle services
+ *
+ * A service for a resource bundle of a given {@code baseName} must have
+ * a fully-qualified class name of the form:
+ *
+ * {@code + ".spi." + + "Provider"}
+ *
+ *
+ * The service type is in a {@code spi} subpackage as it may be packaged in
+ * a module separate from the resource bundle providers.
+ * For example, the service for a resource bundle named
+ * {@code com.example.app.MyResources} must be
+ * {@code com.example.app.spi.MyResourcesProvider}:
+ *
+ *
- * This providers's {@link #getBundle(String, Locale) getBundle} method is called
- * through the resource bundle loading process instead of {@link
- * java.util.ResourceBundle.Control#newBundle(String, Locale, String, ClassLoader, boolean)
- * ResourceBundle.Control.newBundle()}. Refer to {@link ResourceBundle} for
- * details.
+ *
Deploying resource bundle service providers
*
- * @see
- * Resource Bundles in Named Modules
- * @see
- * ResourceBundleProvider Service Providers
+ * Resource bundles can be deployed in one or more service providers
+ * in modules. For example, a provider for a service
+ * named "{@code com.example.app.spi.MyResourcesProvider}"
+ * has the following implementation class:
+ *
+ *
+ *
+ * This example provides "{@code com.example.app.MyResources}"
+ * resource bundle of the French locale. Traditionally resource bundles of
+ * all locales are packaged in the same package as the resource bundle base name.
+ * When deploying resource bundles in more than one modules and two modules
+ * containing a package of the same name, split package,
+ * is not supported, resource bundles in each module can be packaged in
+ * a different package as shown in this example where this provider packages
+ * the resource bundles in per-language package, i.e. {@code com.example.app.fr}
+ * for French locale.
+ *
+ *
A provider can provide more than one services, each of which is a service
+ * for a resource bundle of a different base name.
+ *
+ *
{@link AbstractResourceBundleProvider}
+ * provides the basic implementation for {@code ResourceBundleProvider}
+ * and a subclass can override the {@link
+ * AbstractResourceBundleProvider#toBundleName(String, Locale) toBundleName}
+ * method to return a provider-specific location of the resource to be loaded,
+ * for example, per-language package.
+ * A provider can override {@link #getBundle ResourceBundleProvider.getBundle}
+ * method for example to only search the known supported locales or
+ * return resource bundles in other formats such as XML.
+ *
+ *
The module declaration of this provider module specifies the following
+ * directive:
+ *
+ * provides com.example.app.spi.MyResourcesProvider with com.example.impl.MyResourcesProviderImpl;
+ *
+ *
+ * The module declaration of the consumer module that calls one of the
+ * {@code ResourceBundle.getBundle} factory methods to obtain a resource
+ * bundle from service providers must specify the following directive:
+ *
+ *
+ * {@link ResourceBundle#getBundle(String, Locale)
+ * ResourceBundle.getBundle("com.example.app.MyResource", locale)}
+ * locates and loads the providers for {@code com.example.app.spi.MyResourcesProvider}
+ * service and then invokes {@link #getBundle(String, Locale)
+ * ResourceBundleProvider.getBundle("com.example.app.MyResource", locale)} to
+ * find the resource bundle of the given base name and locale.
+ * If the consumer module is a resource bundle service provider for
+ * {@code com.example.app.spi.MyResourcesProvider}, {@code ResourceBundle.getBundle}
+ * will locate resource bundles only from service providers.
+ * Otherwise, {@code ResourceBundle.getBundle} may continue the search of
+ * the resource bundle in other modules and class path per the specification
+ * of the {@code ResourceBundle.getBundle} method being called.
+ *
+ * @see AbstractResourceBundleProvider
+ * @see
+ * Resource Bundles and Named Modules
+ * @see java.util.ServiceLoader
* @since 9
* @spec JPMS
*/
diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java b/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java
index 942af76b69d..230695206f0 100644
--- a/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java
@@ -64,7 +64,7 @@ import static jdk.internal.module.ClassFileConstants.*;
public final class ModuleInfo {
private final int JAVA_MIN_SUPPORTED_VERSION = 53;
- private final int JAVA_MAX_SUPPORTED_VERSION = 54;
+ private final int JAVA_MAX_SUPPORTED_VERSION = 55;
private static final JavaLangModuleAccess JLMA
= SharedSecrets.getJavaLangModuleAccess();
diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
index 47e1f6d4b15..22b475f9db9 100644
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
@@ -185,7 +185,7 @@ public class ClassReader {
public ClassReader(final byte[] b, final int off, final int len) {
this.b = b;
// checks the class version
- if (readShort(off + 6) > Opcodes.V10) {
+ if (readShort(off + 6) > Opcodes.V11) {
throw new IllegalArgumentException();
}
// parses the constant pool
diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java
index 7ce9d9210c8..8b3ab18626c 100644
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java
@@ -90,6 +90,7 @@ public interface Opcodes {
int V1_8 = 0 << 16 | 52;
int V9 = 0 << 16 | 53;
int V10 = 0 << 16 | 54;
+ int V11 = 0 << 16 | 55;
// access flags
diff --git a/src/java.base/share/classes/java/util/ArraysSupport.java b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
similarity index 83%
rename from src/java.base/share/classes/java/util/ArraysSupport.java
rename to src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
index 31612a7d4f8..cc051df7d31 100644
--- a/src/java.base/share/classes/java/util/ArraysSupport.java
+++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017 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
@@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package java.util;
+package jdk.internal.util;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.Unsafe;
@@ -50,19 +50,19 @@ import jdk.internal.misc.Unsafe;
* responsibility of the caller (direct or otherwise) to perform such checks
* before calling this method.
*/
-class ArraysSupport {
+public class ArraysSupport {
static final Unsafe U = Unsafe.getUnsafe();
private static final boolean BIG_ENDIAN = U.isBigEndian();
- private static final int LOG2_ARRAY_BOOLEAN_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
- private static final int LOG2_ARRAY_BYTE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BYTE_INDEX_SCALE);
- private static final int LOG2_ARRAY_CHAR_INDEX_SCALE = exactLog2(Unsafe.ARRAY_CHAR_INDEX_SCALE);
- private static final int LOG2_ARRAY_SHORT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_SHORT_INDEX_SCALE);
- private static final int LOG2_ARRAY_INT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_INT_INDEX_SCALE);
- private static final int LOG2_ARRAY_LONG_INDEX_SCALE = exactLog2(Unsafe.ARRAY_LONG_INDEX_SCALE);
- private static final int LOG2_ARRAY_FLOAT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_FLOAT_INDEX_SCALE);
- private static final int LOG2_ARRAY_DOUBLE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_DOUBLE_INDEX_SCALE);
+ public static final int LOG2_ARRAY_BOOLEAN_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
+ public static final int LOG2_ARRAY_BYTE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BYTE_INDEX_SCALE);
+ public static final int LOG2_ARRAY_CHAR_INDEX_SCALE = exactLog2(Unsafe.ARRAY_CHAR_INDEX_SCALE);
+ public static final int LOG2_ARRAY_SHORT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_SHORT_INDEX_SCALE);
+ public static final int LOG2_ARRAY_INT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_INT_INDEX_SCALE);
+ public static final int LOG2_ARRAY_LONG_INDEX_SCALE = exactLog2(Unsafe.ARRAY_LONG_INDEX_SCALE);
+ public static final int LOG2_ARRAY_FLOAT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_FLOAT_INDEX_SCALE);
+ public static final int LOG2_ARRAY_DOUBLE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_DOUBLE_INDEX_SCALE);
private static final int LOG2_BYTE_BIT_SIZE = exactLog2(Byte.SIZE);
@@ -107,10 +107,10 @@ class ArraysSupport {
* the tail of the two arrays.
*/
@HotSpotIntrinsicCandidate
- static int vectorizedMismatch(Object a, long aOffset,
- Object b, long bOffset,
- int length,
- int log2ArrayIndexScale) {
+ public static int vectorizedMismatch(Object a, long aOffset,
+ Object b, long bOffset,
+ int length,
+ int log2ArrayIndexScale) {
// assert a.getClass().isArray();
// assert b.getClass().isArray();
// assert 0 <= length <= sizeOf(a)
@@ -161,9 +161,9 @@ class ArraysSupport {
// Booleans
// Each boolean element takes up one byte
- static int mismatch(boolean[] a,
- boolean[] b,
- int length) {
+ public static int mismatch(boolean[] a,
+ boolean[] b,
+ int length) {
int i = 0;
if (length > 7) {
i = vectorizedMismatch(
@@ -181,9 +181,9 @@ class ArraysSupport {
return -1;
}
- static int mismatch(boolean[] a, int aFromIndex,
- boolean[] b, int bFromIndex,
- int length) {
+ public static int mismatch(boolean[] a, int aFromIndex,
+ boolean[] b, int bFromIndex,
+ int length) {
int i = 0;
if (length > 7) {
int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex;
@@ -219,9 +219,9 @@ class ArraysSupport {
* no mismatch. The index will be within the range of (inclusive) 0 to
* (exclusive) the smaller of the two array lengths.
*/
- static int mismatch(byte[] a,
- byte[] b,
- int length) {
+ public static int mismatch(byte[] a,
+ byte[] b,
+ int length) {
// ISSUE: defer to index receiving methods if performance is good
// assert length <= a.length
// assert length <= b.length
@@ -264,9 +264,9 @@ class ArraysSupport {
* otherwise -1 if no mismatch. The index will be within the range of
* (inclusive) 0 to (exclusive) the smaller of the two array bounds.
*/
- static int mismatch(byte[] a, int aFromIndex,
- byte[] b, int bFromIndex,
- int length) {
+ public static int mismatch(byte[] a, int aFromIndex,
+ byte[] b, int bFromIndex,
+ int length) {
// assert 0 <= aFromIndex < a.length
// assert 0 <= aFromIndex + length <= a.length
// assert 0 <= bFromIndex < b.length
@@ -295,9 +295,9 @@ class ArraysSupport {
// Chars
- static int mismatch(char[] a,
- char[] b,
- int length) {
+ public static int mismatch(char[] a,
+ char[] b,
+ int length) {
int i = 0;
if (length > 3) {
i = vectorizedMismatch(
@@ -315,9 +315,9 @@ class ArraysSupport {
return -1;
}
- static int mismatch(char[] a, int aFromIndex,
- char[] b, int bFromIndex,
- int length) {
+ public static int mismatch(char[] a, int aFromIndex,
+ char[] b, int bFromIndex,
+ int length) {
int i = 0;
if (length > 3) {
int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
@@ -340,9 +340,9 @@ class ArraysSupport {
// Shorts
- static int mismatch(short[] a,
- short[] b,
- int length) {
+ public static int mismatch(short[] a,
+ short[] b,
+ int length) {
int i = 0;
if (length > 3) {
i = vectorizedMismatch(
@@ -360,9 +360,9 @@ class ArraysSupport {
return -1;
}
- static int mismatch(short[] a, int aFromIndex,
- short[] b, int bFromIndex,
- int length) {
+ public static int mismatch(short[] a, int aFromIndex,
+ short[] b, int bFromIndex,
+ int length) {
int i = 0;
if (length > 3) {
int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
@@ -385,9 +385,9 @@ class ArraysSupport {
// Ints
- static int mismatch(int[] a,
- int[] b,
- int length) {
+ public static int mismatch(int[] a,
+ int[] b,
+ int length) {
int i = 0;
if (length > 1) {
i = vectorizedMismatch(
@@ -405,9 +405,9 @@ class ArraysSupport {
return -1;
}
- static int mismatch(int[] a, int aFromIndex,
- int[] b, int bFromIndex,
- int length) {
+ public static int mismatch(int[] a, int aFromIndex,
+ int[] b, int bFromIndex,
+ int length) {
int i = 0;
if (length > 1) {
int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
@@ -430,15 +430,15 @@ class ArraysSupport {
// Floats
- static int mismatch(float[] a,
- float[] b,
- int length) {
+ public static int mismatch(float[] a,
+ float[] b,
+ int length) {
return mismatch(a, 0, b, 0, length);
}
- static int mismatch(float[] a, int aFromIndex,
- float[] b, int bFromIndex,
- int length) {
+ public static int mismatch(float[] a, int aFromIndex,
+ float[] b, int bFromIndex,
+ int length) {
int i = 0;
if (length > 1) {
int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
@@ -475,9 +475,9 @@ class ArraysSupport {
// Long
- static int mismatch(long[] a,
- long[] b,
- int length) {
+ public static int mismatch(long[] a,
+ long[] b,
+ int length) {
if (length == 0) {
return -1;
}
@@ -488,9 +488,9 @@ class ArraysSupport {
return i >= 0 ? i : -1;
}
- static int mismatch(long[] a, int aFromIndex,
- long[] b, int bFromIndex,
- int length) {
+ public static int mismatch(long[] a, int aFromIndex,
+ long[] b, int bFromIndex,
+ int length) {
if (length == 0) {
return -1;
}
@@ -506,15 +506,15 @@ class ArraysSupport {
// Double
- static int mismatch(double[] a,
- double[] b,
- int length) {
+ public static int mismatch(double[] a,
+ double[] b,
+ int length) {
return mismatch(a, 0, b, 0, length);
}
- static int mismatch(double[] a, int aFromIndex,
- double[] b, int bFromIndex,
- int length) {
+ public static int mismatch(double[] a, int aFromIndex,
+ double[] b, int bFromIndex,
+ int length) {
if (length == 0) {
return -1;
}
diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java
index ac0cd9995bc..dbae779fe0e 100644
--- a/src/java.base/share/classes/module-info.java
+++ b/src/java.base/share/classes/module-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -142,7 +142,7 @@ module java.base {
java.instrument,
java.logging;
exports jdk.internal.jmod to
- jdk.compiler, // reflective dependency
+ jdk.compiler,
jdk.jlink;
exports jdk.internal.logger to
java.logging;
@@ -172,7 +172,7 @@ module java.base {
java.xml,
jdk.attach,
jdk.charsets,
- jdk.compiler, // reflective dependency
+ jdk.compiler,
jdk.incubator.httpclient,
jdk.jdeps,
jdk.jlink,
diff --git a/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java b/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java
index 2a3775da7df..ba86dd87875 100644
--- a/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, 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
@@ -108,7 +108,29 @@ final class HandshakeHash {
* a hash for the certificate verify message is required.
*/
HandshakeHash(boolean needCertificateVerify) {
- clonesNeeded = needCertificateVerify ? 4 : 3;
+ // We may rework the code later, but for now we use hard-coded number
+ // of clones if the underlying MessageDigests are not cloneable.
+ //
+ // The number used here is based on the current handshake protocols and
+ // implementation. It may be changed if the handshake processe gets
+ // changed in the future, for example adding a new extension that
+ // requires handshake hash. Please be careful about the number of
+ // clones if additional handshak hash is required in the future.
+ //
+ // For the current implementation, the handshake hash is required for
+ // the following items:
+ // . CertificateVerify handshake message (optional)
+ // . client Finished handshake message
+ // . server Finished Handshake message
+ // . the extended Master Secret extension [RFC 7627]
+ //
+ // Note that a late call to server setNeedClientAuth dose not update
+ // the number of clones. We may address the issue later.
+ //
+ // Note for safety, we allocate one more clone for the current
+ // implementation. We may consider it more carefully in the future
+ // for the exact number or rework the code in a different way.
+ clonesNeeded = needCertificateVerify ? 5 : 4;
}
void reserve(ByteBuffer input) {
@@ -335,7 +357,8 @@ final class HandshakeHash {
if (finMD != null) return;
try {
- finMD = CloneableDigest.getDigest(normalizeAlgName(s), 2);
+ // See comment in the contructor.
+ finMD = CloneableDigest.getDigest(normalizeAlgName(s), 4);
} catch (NoSuchAlgorithmException e) {
throw new Error(e);
}
diff --git a/src/java.base/share/native/include/classfile_constants.h b/src/java.base/share/native/include/classfile_constants.h.template
similarity index 99%
rename from src/java.base/share/native/include/classfile_constants.h
rename to src/java.base/share/native/include/classfile_constants.h.template
index 3b63f31c6e8..1046b54b37a 100644
--- a/src/java.base/share/native/include/classfile_constants.h
+++ b/src/java.base/share/native/include/classfile_constants.h.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, 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
@@ -31,8 +31,8 @@ extern "C" {
#endif
/* Classfile version number for this information */
-#define JVM_CLASSFILE_MAJOR_VERSION 54
-#define JVM_CLASSFILE_MINOR_VERSION 0
+#define JVM_CLASSFILE_MAJOR_VERSION @@VERSION_CLASSFILE_MAJOR@@
+#define JVM_CLASSFILE_MINOR_VERSION @@VERSION_CLASSFILE_MINOR@@
/* Flags */
diff --git a/src/java.base/share/native/libjava/System.c b/src/java.base/share/native/libjava/System.c
index 9116b8d8265..5c5060af124 100644
--- a/src/java.base/share/native/libjava/System.c
+++ b/src/java.base/share/native/libjava/System.c
@@ -114,9 +114,6 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
#define VENDOR_URL_BUG "http://bugreport.java.com/bugreport/"
#endif
-#define JAVA_MAX_SUPPORTED_VERSION 54
-#define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
-
#ifdef JAVA_SPECIFICATION_VENDOR /* Third party may NOT overwrite this. */
#error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
#else
@@ -222,8 +219,8 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
PUTPROP(props, "java.vendor.url", VENDOR_URL);
PUTPROP(props, "java.vendor.url.bug", VENDOR_URL_BUG);
- jio_snprintf(buf, sizeof(buf), "%d.%d", JAVA_MAX_SUPPORTED_VERSION,
- JAVA_MAX_SUPPORTED_MINOR_VERSION);
+ jio_snprintf(buf, sizeof(buf), "%d.%d", JVM_CLASSFILE_MAJOR_VERSION,
+ JVM_CLASSFILE_MINOR_VERSION);
PUTPROP(props, "java.class.version", buf);
if (sprops->awt_toolkit) {
diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
index 5d8124aeda6..6a0c8f55e6e 100644
--- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
+++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
@@ -57,6 +57,7 @@ public enum SourceVersion {
* 1.8: lambda expressions and default methods
* 9: modules, small cleanups to 1.7 and 1.8 changes
* 10: local-variable type inference (var)
+ * 11: to be determined changes
*/
/**
@@ -162,7 +163,15 @@ public enum SourceVersion {
*
* @since 10
*/
- RELEASE_10;
+ RELEASE_10,
+
+ /**
+ * The version recognized by the Java Platform, Standard Edition
+ * 11.
+ *
+ * @since 11
+ */
+ RELEASE_11;
// Note that when adding constants for newer releases, the
// behavior of latest() and latestSupported() must be updated too.
@@ -173,7 +182,7 @@ public enum SourceVersion {
* @return the latest source version that can be modeled
*/
public static SourceVersion latest() {
- return RELEASE_10;
+ return RELEASE_11;
}
private static final SourceVersion latestSupported = getLatestSupported();
@@ -183,6 +192,8 @@ public enum SourceVersion {
String specVersion = System.getProperty("java.specification.version");
switch (specVersion) {
+ case "11":
+ return RELEASE_11;
case "10":
return RELEASE_10;
case "9":
diff --git a/src/java.desktop/share/classes/java/awt/Toolkit.java b/src/java.desktop/share/classes/java/awt/Toolkit.java
index 8a36c2977b1..7a4372ace66 100644
--- a/src/java.desktop/share/classes/java/awt/Toolkit.java
+++ b/src/java.desktop/share/classes/java/awt/Toolkit.java
@@ -678,6 +678,11 @@ public abstract class Toolkit {
* If the connection to the specified URL requires
* either {@code URLPermission} or {@code SocketPermission},
* then {@code URLPermission} is used for security checks.
+ * For compatibility with pre-1.2 security managers, if the access
+ * is denied with {@code FilePermission} or {@code SocketPermission},
+ * the method throws the {@code SecurityException}
+ * if the corresponding 1.1-style SecurityManager.checkXXX method
+ * also denies permission.
* @param url the URL to use in fetching the pixel data.
* @return an image which gets its pixel data from
* the specified URL.
@@ -719,6 +724,11 @@ public abstract class Toolkit {
* If the connection to the specified URL requires
* either {@code URLPermission} or {@code SocketPermission},
* then {@code URLPermission} is used for security checks.
+ * For compatibility with pre-1.2 security managers, if the access
+ * is denied with {@code FilePermission} or {@code SocketPermission},
+ * the method throws {@code SecurityException}
+ * if the corresponding 1.1-style SecurityManager.checkXXX method
+ * also denies permission.
* @param url the URL to use in fetching the pixel data.
* @return an image which gets its pixel data from
* the specified URL.
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
index 23447f62aae..107b94598ca 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
@@ -78,8 +78,11 @@ public enum Source {
/** 1.9 modularity. */
JDK9("9"),
- /** 1.10 covers the to be determined language features that will be added in JDK 10. */
- JDK10("10");
+ /** 1.10 local-variable type inference (var). */
+ JDK10("10"),
+
+ /** 1.11 covers the to be determined language features that will be added in JDK 11. */
+ JDK11("11");
private static final Context.Key sourceKey = new Context.Key<>();
@@ -108,6 +111,7 @@ public enum Source {
tab.put("1.8", JDK8); // Make 8 an alias for 1.8
tab.put("1.9", JDK9); // Make 9 an alias for 1.9
tab.put("1.10", JDK10); // Make 10 an alias for 1.10
+ // Decline to make 1.11 an alias for 11.
}
private Source(String name) {
@@ -125,6 +129,7 @@ public enum Source {
}
public Target requiredTarget() {
+ if (this.compareTo(JDK11) >= 0) return Target.JDK1_11;
if (this.compareTo(JDK10) >= 0) return Target.JDK1_10;
if (this.compareTo(JDK9) >= 0) return Target.JDK1_9;
if (this.compareTo(JDK8) >= 0) return Target.JDK1_8;
@@ -247,6 +252,8 @@ public enum Source {
return RELEASE_9;
case JDK10:
return RELEASE_10;
+ case JDK11:
+ return RELEASE_11;
default:
return null;
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
index 0f4d3fecd07..fcaad5c2d0e 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
@@ -1628,9 +1628,6 @@ public abstract class Symbol extends AnnoConstruct implements Element {
/** The parameters of the method. */
public List params = null;
- /** The names of the parameters */
- public List savedParameterNames;
-
/** For an annotation type element, its default value if any.
* The value is null if none appeared in the method
* declaration.
@@ -1886,57 +1883,18 @@ public abstract class Symbol extends AnnoConstruct implements Element {
public List params() {
owner.complete();
if (params == null) {
- // If ClassReader.saveParameterNames has been set true, then
- // savedParameterNames will be set to a list of names that
- // matches the types in type.getParameterTypes(). If any names
- // were not found in the class file, those names in the list will
- // be set to the empty name.
- // If ClassReader.saveParameterNames has been set false, then
- // savedParameterNames will be null.
- List paramNames = savedParameterNames;
- savedParameterNames = null;
- // discard the provided names if the list of names is the wrong size.
- if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
- paramNames = List.nil();
- }
- ListBuffer buf = new ListBuffer<>();
- List remaining = paramNames;
- // assert: remaining and paramNames are both empty or both
- // have same cardinality as type.getParameterTypes()
+ ListBuffer newParams = new ListBuffer<>();
int i = 0;
for (Type t : type.getParameterTypes()) {
- Name paramName;
- if (remaining.isEmpty()) {
- // no names for any parameters available
- paramName = createArgName(i, paramNames);
- } else {
- paramName = remaining.head;
- remaining = remaining.tail;
- if (paramName.isEmpty()) {
- // no name for this specific parameter
- paramName = createArgName(i, paramNames);
- }
- }
- buf.append(new VarSymbol(PARAMETER, paramName, t, this));
- i++;
- }
- params = buf.toList();
- }
- return params;
- }
+ Name paramName = name.table.fromString("arg" + i);
+ VarSymbol param = new VarSymbol(PARAMETER, paramName, t, this);
+ newParams.append(param);
- // Create a name for the argument at position 'index' that is not in
- // the exclude list. In normal use, either no names will have been
- // provided, in which case the exclude list is empty, or all the names
- // will have been provided, in which case this method will not be called.
- private Name createArgName(int index, List exclude) {
- String prefix = "arg";
- while (true) {
- Name argName = name.table.fromString(prefix + index);
- if (!exclude.contains(argName))
- return argName;
- prefix += "$";
+ }
+ params = newParams.toList();
}
+ Assert.checkNonNull(params);
+ return params;
}
public Symbol asMemberOf(Type site, Types types) {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
index 4f1d7142bbb..b3999f56571 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
@@ -1976,8 +1976,8 @@ public class Check {
types.covariantReturnType(rt2, rt1, types.noWarnings)) ||
checkCommonOverriderIn(s1,s2,site);
if (!compat) {
- log.error(pos, Errors.TypesIncompatibleDiffRet(t1, t2, s2.name +
- "(" + types.memberType(t2, s2).getParameterTypes() + ")"));
+ log.error(pos, Errors.TypesIncompatible(t1, t2,
+ Fragments.IncompatibleDiffRet(s2.name, types.memberType(t2, s2).getParameterTypes())));
return s2;
}
} else if (checkNameClash((ClassSymbol)site.tsym, s1, s2) &&
@@ -2563,20 +2563,22 @@ public class Check {
//strong semantics - issue an error if two sibling interfaces
//have two override-equivalent defaults - or if one is abstract
//and the other is default
- String errKey;
+ Fragment diagKey;
Symbol s1 = defaults.first();
Symbol s2;
if (defaults.size() > 1) {
- errKey = "types.incompatible.unrelated.defaults";
s2 = defaults.toList().tail.head;
+ diagKey = Fragments.IncompatibleUnrelatedDefaults(Kinds.kindName(site.tsym), site,
+ m.name, types.memberType(site, m).getParameterTypes(),
+ s1.location(), s2.location());
+
} else {
- errKey = "types.incompatible.abstract.default";
s2 = abstracts.first();
+ diagKey = Fragments.IncompatibleAbstractDefault(Kinds.kindName(site.tsym), site,
+ m.name, types.memberType(site, m).getParameterTypes(),
+ s1.location(), s2.location());
}
- log.error(pos, errKey,
- Kinds.kindName(site.tsym), site,
- m.name, types.memberType(site, m).getParameterTypes(),
- s1.location(), s2.location());
+ log.error(pos, Errors.TypesIncompatible(s1.location().type, s2.location().type, diagKey));
break;
}
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
index fe4cb8529de..ec60235650e 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -421,6 +421,12 @@ public class Enter extends JCTree.Visitor {
// We are seeing a member class.
c = syms.enterClass(env.toplevel.modle, tree.name, (TypeSymbol)owner);
if (c.owner != owner) {
+ if (c.name != tree.name) {
+ log.error(tree.pos(), Errors.SameBinaryName(c.name, tree.name));
+ result = types.createErrorType(tree.name, (TypeSymbol)owner, Type.noType);
+ tree.sym = (ClassSymbol)result.tsym;
+ return;
+ }
//anonymous class loaded from a classfile may be recreated from source (see below)
//if this class is a member of such an anonymous class, fix the owner:
Assert.check(owner.owner.kind != TYP, owner::toString);
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
index 6f63d163686..79596fc6cdd 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -27,6 +27,8 @@ package com.sun.tools.javac.file;
import java.io.File;
import java.io.IOException;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleFinder;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -77,11 +79,6 @@ import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.JDK9Wrappers.Configuration;
-import com.sun.tools.javac.util.JDK9Wrappers.Layer;
-import com.sun.tools.javac.util.JDK9Wrappers.ModuleFinder;
-import com.sun.tools.javac.util.JDK9Wrappers.Module;
-import com.sun.tools.javac.util.JDK9Wrappers.ServiceLoaderHelper;
import static java.nio.file.FileVisitOption.FOLLOW_LINKS;
@@ -980,14 +977,14 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
public ServiceLoader getServiceLoader(Location location, Class service) throws IOException {
nullCheck(location);
nullCheck(service);
- Module.getModule(getClass()).addUses(service);
+ getClass().getModule().addUses(service);
if (location.isModuleOrientedLocation()) {
Collection paths = locations.getLocation(location);
ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[paths.size()]));
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer.configuration().resolveAndBind(ModuleFinder.of(), finder, Collections.emptySet());
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, ClassLoader.getSystemClassLoader());
- return ServiceLoaderHelper.load(layer, service);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, ClassLoader.getSystemClassLoader());
+ return ServiceLoader.load(layer, service);
} else {
return ServiceLoader.load(service, getClassLoader(location));
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
index e91c392a425..f6ada58e756 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -77,6 +77,8 @@ import javax.tools.StandardJavaFileManager;
import javax.tools.StandardJavaFileManager.PathFactory;
import javax.tools.StandardLocation;
+import jdk.internal.jmod.JmodFile;
+
import com.sun.tools.javac.code.Lint;
import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.main.Option;
@@ -84,7 +86,6 @@ import com.sun.tools.javac.resources.CompilerProperties.Errors;
import com.sun.tools.javac.resources.CompilerProperties.Warnings;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.JDK9Wrappers;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.jvm.ModuleNameReader;
@@ -1451,7 +1452,7 @@ public class Locations {
if (p.getFileName().toString().endsWith(".jmod")) {
try {
// check if the JMOD file is valid
- JDK9Wrappers.JmodFile.checkMagic(p);
+ JmodFile.checkMagic(p);
// No JMOD file system. Use JarFileSystem to
// workaround for now
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java
index 6e80995e509..bdb8a8bafa3 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java
@@ -111,7 +111,8 @@ public class ClassFile {
V51(51, 0), // JDK 1.7
V52(52, 0), // JDK 1.8: lambda, type annos, param names
V53(53, 0), // JDK 1.9: modules, indy string concat
- V54(54, 0); // JDK 10
+ V54(54, 0), // JDK 10
+ V55(55, 0); // JDK 11: constant dynamic
Version(int major, int minor) {
this.major = major;
this.minor = minor;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java
index 90cd8bee4aa..e8c48acc45e 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java
@@ -192,6 +192,26 @@ public class ClassReader {
*/
int[] parameterNameIndices;
+ /**
+ * A table to hold annotations for method parameters.
+ */
+ ParameterAnnotations[] parameterAnnotations;
+
+ /**
+ * A holder for parameter annotations.
+ */
+ static class ParameterAnnotations {
+ List proxies;
+
+ void add(List newAnnotations) {
+ if (proxies == null) {
+ proxies = newAnnotations;
+ } else {
+ proxies = proxies.prependList(newAnnotations);
+ }
+ }
+ }
+
/**
* Whether or not any parameter names have been found.
*/
@@ -1218,7 +1238,7 @@ public class ClassReader {
new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
protected void read(Symbol sym, int attrLen) {
- attachParameterAnnotations(sym);
+ readParameterAnnotations(sym);
}
},
@@ -1230,7 +1250,7 @@ public class ClassReader {
new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
protected void read(Symbol sym, int attrLen) {
- attachParameterAnnotations(sym);
+ readParameterAnnotations(sym);
}
},
@@ -1288,10 +1308,14 @@ public class ClassReader {
int numEntries = nextByte();
parameterNameIndices = new int[numEntries];
haveParameterNameIndices = true;
+ int index = 0;
for (int i = 0; i < numEntries; i++) {
int nameIndex = nextChar();
int flags = nextChar();
- parameterNameIndices[i] = nameIndex;
+ if ((flags & (Flags.MANDATED | Flags.SYNTHETIC)) != 0) {
+ continue;
+ }
+ parameterNameIndices[index++] = nameIndex;
}
}
bp = newbp;
@@ -1580,66 +1604,83 @@ public class ClassReader {
* Reading Java-language annotations
***********************************************************************/
+ /**
+ * Save annotations.
+ */
+ List readAnnotations() {
+ int numAttributes = nextChar();
+ ListBuffer annotations = new ListBuffer<>();
+ for (int i = 0; i < numAttributes; i++) {
+ annotations.append(readCompoundAnnotation());
+ }
+ return annotations.toList();
+ }
+
/** Attach annotations.
*/
void attachAnnotations(final Symbol sym) {
- int numAttributes = nextChar();
- if (numAttributes != 0) {
- ListBuffer proxies = new ListBuffer<>();
- for (int i = 0; i v: proxy.values) {
- if (v.fst == names.value && v.snd instanceof Attribute.Constant) {
- Attribute.Constant c = (Attribute.Constant) v.snd;
- if (c.type == syms.intType && ((Integer) c.value) > profile.value) {
- sym.flags_field |= NOT_IN_PROFILE;
- }
- }
- }
- }
- } else {
- if (proxy.type.tsym == syms.annotationTargetType.tsym) {
- target = proxy;
- } else if (proxy.type.tsym == syms.repeatableType.tsym) {
- repeatable = proxy;
- } else if (proxy.type.tsym == syms.deprecatedType.tsym) {
- sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION);
- for (Pair v : proxy.values) {
- if (v.fst == names.forRemoval && v.snd instanceof Attribute.Constant) {
- Attribute.Constant c = (Attribute.Constant) v.snd;
- if (c.type == syms.booleanType && ((Integer) c.value) != 0) {
- sym.flags_field |= DEPRECATED_REMOVAL;
- }
- }
- }
- }
-
- proxies.append(proxy);
- }
- }
- annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
- }
+ attachAnnotations(sym, readAnnotations());
}
- /** Attach parameter annotations.
+ /**
+ * Attach annotations.
*/
- void attachParameterAnnotations(final Symbol method) {
- final MethodSymbol meth = (MethodSymbol)method;
- int numParameters = buf[bp++] & 0xFF;
- List parameters = meth.params();
- int pnum = 0;
- while (parameters.tail != null) {
- attachAnnotations(parameters.head);
- parameters = parameters.tail;
- pnum++;
+ void attachAnnotations(final Symbol sym, List annotations) {
+ if (annotations.isEmpty()) {
+ return;
}
- if (pnum != numParameters) {
+ ListBuffer proxies = new ListBuffer<>();
+ for (CompoundAnnotationProxy proxy : annotations) {
+ if (proxy.type.tsym == syms.proprietaryType.tsym)
+ sym.flags_field |= PROPRIETARY;
+ else if (proxy.type.tsym == syms.profileType.tsym) {
+ if (profile != Profile.DEFAULT) {
+ for (Pair v : proxy.values) {
+ if (v.fst == names.value && v.snd instanceof Attribute.Constant) {
+ Attribute.Constant c = (Attribute.Constant)v.snd;
+ if (c.type == syms.intType && ((Integer)c.value) > profile.value) {
+ sym.flags_field |= NOT_IN_PROFILE;
+ }
+ }
+ }
+ }
+ } else {
+ if (proxy.type.tsym == syms.annotationTargetType.tsym) {
+ target = proxy;
+ } else if (proxy.type.tsym == syms.repeatableType.tsym) {
+ repeatable = proxy;
+ } else if (proxy.type.tsym == syms.deprecatedType.tsym) {
+ sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION);
+ for (Pair v : proxy.values) {
+ if (v.fst == names.forRemoval && v.snd instanceof Attribute.Constant) {
+ Attribute.Constant c = (Attribute.Constant)v.snd;
+ if (c.type == syms.booleanType && ((Integer)c.value) != 0) {
+ sym.flags_field |= DEPRECATED_REMOVAL;
+ }
+ }
+ }
+ }
+ proxies.append(proxy);
+ }
+ }
+ annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
+ }
+
+ /** Read parameter annotations.
+ */
+ void readParameterAnnotations(Symbol meth) {
+ int numParameters = buf[bp++] & 0xFF;
+ if (parameterAnnotations == null) {
+ parameterAnnotations = new ParameterAnnotations[numParameters];
+ } else if (parameterAnnotations.length != numParameters) {
throw badClassFile("bad.runtime.invisible.param.annotations", meth);
}
+ for (int pnum = 0; pnum < numParameters; pnum++) {
+ if (parameterAnnotations[pnum] == null) {
+ parameterAnnotations[pnum] = new ParameterAnnotations();
+ }
+ parameterAnnotations[pnum].add(readAnnotations());
+ }
}
void attachTypeAnnotations(final Symbol sym) {
@@ -2403,8 +2444,7 @@ public class ClassReader {
} finally {
currentOwner = prevOwner;
}
- if (saveParameterNames)
- setParameterNames(m, type);
+ setParameters(m, type);
if ((flags & VARARGS) != 0) {
final Type last = type.getParameterTypes().last();
@@ -2457,22 +2497,17 @@ public class ClassReader {
}
/**
- * Set the parameter names for a symbol from the name index in the
- * parameterNameIndicies array. The type of the symbol may have changed
- * while reading the method attributes (see the Signature attribute).
- * This may be because of generic information or because anonymous
- * synthetic parameters were added. The original type (as read from
- * the method descriptor) is used to help guess the existence of
+ * Set the parameters for a method symbol, including any names and
+ * annotations that were read.
+ *
+ *
The type of the symbol may have changed while reading the
+ * method attributes (see the Signature attribute). This may be
+ * because of generic information or because anonymous synthetic
+ * parameters were added. The original type (as read from the
+ * method descriptor) is used to help guess the existence of
* anonymous synthetic parameters.
- * On completion, sym.savedParameter names will either be null (if
- * no parameter names were found in the class file) or will be set to a
- * list of names, one per entry in sym.type.getParameterTypes, with
- * any missing names represented by the empty name.
*/
- void setParameterNames(MethodSymbol sym, Type jvmType) {
- // if no names were found in the class file, there's nothing more to do
- if (!haveParameterNameIndices)
- return;
+ void setParameters(MethodSymbol sym, Type jvmType) {
// If we get parameter names from MethodParameters, then we
// don't need to skip.
int firstParam = 0;
@@ -2483,16 +2518,16 @@ public class ClassReader {
// make a corresponding allowance here for the position of
// the first parameter. Note that this assumes the
// skipped parameter has a width of 1 -- i.e. it is not
- // a double width type (long or double.)
- if (sym.name == names.init && currentOwner.hasOuterInstance()) {
- // Sometimes anonymous classes don't have an outer
- // instance, however, there is no reliable way to tell so
- // we never strip this$n
- if (!currentOwner.name.isEmpty())
- firstParam += 1;
- }
+ // a double width type (long or double.)
+ if (sym.name == names.init && currentOwner.hasOuterInstance()) {
+ // Sometimes anonymous classes don't have an outer
+ // instance, however, there is no reliable way to tell so
+ // we never strip this$n
+ if (!currentOwner.name.isEmpty())
+ firstParam += 1;
+ }
- if (sym.type != jvmType) {
+ if (sym.type != jvmType) {
// reading the method attributes has caused the
// symbol's type to be changed. (i.e. the Signature
// attribute.) This may happen if there are hidden
@@ -2502,21 +2537,55 @@ public class ClassReader {
// at the beginning, and so skip over them. The
// primary case for this is two hidden parameters
// passed into Enum constructors.
- int skip = Code.width(jvmType.getParameterTypes())
- - Code.width(sym.type.getParameterTypes());
- firstParam += skip;
- }
+ int skip = Code.width(jvmType.getParameterTypes())
+ - Code.width(sym.type.getParameterTypes());
+ firstParam += skip;
+ }
}
List paramNames = List.nil();
- int index = firstParam;
+ ListBuffer params = new ListBuffer<>();
+ int nameIndex = firstParam;
+ int annotationIndex = 0;
for (Type t: sym.type.getParameterTypes()) {
- int nameIdx = (index < parameterNameIndices.length
- ? parameterNameIndices[index] : 0);
- Name name = nameIdx == 0 ? names.empty : readName(nameIdx);
+ Name name = parameterName(nameIndex, paramNames);
paramNames = paramNames.prepend(name);
- index += sawMethodParameters ? 1 : Code.width(t);
+ VarSymbol param = new VarSymbol(PARAMETER, name, t, sym);
+ params.append(param);
+ if (parameterAnnotations != null) {
+ ParameterAnnotations annotations = parameterAnnotations[annotationIndex];
+ if (annotations != null && annotations.proxies != null
+ && !annotations.proxies.isEmpty()) {
+ annotate.normal(new AnnotationCompleter(param, annotations.proxies));
+ }
+ }
+ nameIndex += sawMethodParameters ? 1 : Code.width(t);
+ annotationIndex++;
+ }
+ if (parameterAnnotations != null && parameterAnnotations.length != annotationIndex) {
+ throw badClassFile("bad.runtime.invisible.param.annotations", sym);
+ }
+ Assert.checkNull(sym.params);
+ sym.params = params.toList();
+ parameterAnnotations = null;
+ parameterNameIndices = null;
+ }
+
+
+ // Returns the name for the parameter at position 'index', either using
+ // names read from the MethodParameters, or by synthesizing a name that
+ // is not on the 'exclude' list.
+ private Name parameterName(int index, List exclude) {
+ if (parameterNameIndices != null && index < parameterNameIndices.length
+ && parameterNameIndices[index] != 0) {
+ return readName(parameterNameIndices[index]);
+ }
+ String prefix = "arg";
+ while (true) {
+ Name argName = names.fromString(prefix + exclude.size());
+ if (!exclude.contains(argName))
+ return argName;
+ prefix += "$";
}
- sym.savedParameterNames = paramNames.reverse();
}
/**
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java
index 1dceec9f725..c05c2f6488f 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java
@@ -40,9 +40,9 @@ import static com.sun.tools.javac.main.Option.PROFILE;
* deletion without notice.
*/
public enum Profile {
- COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10),
- COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10),
- COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10),
+ COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11),
+ COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11),
+ COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11),
DEFAULT {
@Override
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
index b0413afb743..2c7654df778 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
@@ -64,7 +64,10 @@ public enum Target {
JDK1_9("1.9", 53, 0),
/** JDK 10. */
- JDK1_10("1.10", 54, 0);
+ JDK1_10("1.10", 54, 0),
+
+ /** JDK 11. */
+ JDK1_11("11", 55, 0);
private static final Context.Key targetKey = new Context.Key<>();
@@ -95,6 +98,7 @@ public enum Target {
tab.put("8", JDK1_8);
tab.put("9", JDK1_9);
tab.put("10", JDK1_10);
+ tab.put("11", JDK1_11);
}
public final String name;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
index 9210793710b..a038e03521d 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -27,6 +27,7 @@ package com.sun.tools.javac.main;
import java.io.FileWriter;
import java.io.PrintWriter;
+import java.lang.module.ModuleDescriptor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -47,6 +48,8 @@ import java.util.stream.StreamSupport;
import javax.lang.model.SourceVersion;
+import jdk.internal.misc.VM;
+
import com.sun.tools.doclint.DocLint;
import com.sun.tools.javac.code.Lint;
import com.sun.tools.javac.code.Lint.LintCategory;
@@ -57,7 +60,6 @@ import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.platform.PlatformProvider;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.util.Assert;
-import com.sun.tools.javac.util.JDK9Wrappers;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Log.PrefixKind;
import com.sun.tools.javac.util.Log.WriterKind;
@@ -650,21 +652,11 @@ public enum Option {
if (arg.isEmpty()) {
throw helper.newInvalidValueException("err.no.value.for.option", option);
} else {
+ // use official parser if available
try {
- Class.forName(JDK9Wrappers.ModuleDescriptor.Version.CLASSNAME);
- // use official parser if available
- try {
- JDK9Wrappers.ModuleDescriptor.Version.parse(arg);
- } catch (IllegalArgumentException e) {
- throw helper.newInvalidValueException("err.bad.value.for.option", option, arg);
- }
- } catch (ClassNotFoundException ex) {
- // fall-back to simplistic rules when running on older platform
- if (!(arg.charAt(0) >= '0' && arg.charAt(0) <= '9') ||
- arg.endsWith("-") ||
- arg.endsWith("+")) {
- throw helper.newInvalidValueException("err.bad.value.for.option", option, arg);
- }
+ ModuleDescriptor.Version.parse(arg);
+ } catch (IllegalArgumentException e) {
+ throw helper.newInvalidValueException("err.bad.value.for.option", option, arg);
}
}
super.process(helper, option, arg);
@@ -717,41 +709,36 @@ public enum Option {
HIDDEN, BASIC) {
@Override
public void process(OptionHelper helper, String option) throws InvalidValueException {
- try {
- Class.forName(JDK9Wrappers.VMHelper.CLASSNAME);
- String[] runtimeArgs = JDK9Wrappers.VMHelper.getRuntimeArguments();
- for (String arg : runtimeArgs) {
- // Handle any supported runtime options; ignore all others.
- // The runtime arguments always use the single token form, e.g. "--name=value".
- for (Option o : getSupportedRuntimeOptions()) {
- if (o.matches(arg)) {
- switch (o) {
- case ADD_MODULES:
- int eq = arg.indexOf('=');
- Assert.check(eq > 0, () -> ("invalid runtime option:" + arg));
- // --add-modules=ALL-DEFAULT is not supported at compile-time
- // so remove it from list, and only process the rest
- // if the set is non-empty.
- // Note that --add-modules=ALL-DEFAULT is automatically added
- // by the standard javac launcher.
- String mods = Arrays.stream(arg.substring(eq + 1).split(","))
- .filter(s -> !s.isEmpty() && !s.equals("ALL-DEFAULT"))
- .collect(Collectors.joining(","));
- if (!mods.isEmpty()) {
- String updatedArg = arg.substring(0, eq + 1) + mods;
- o.handleOption(helper, updatedArg, Collections.emptyIterator());
- }
- break;
- default:
- o.handleOption(helper, arg, Collections.emptyIterator());
- break;
- }
- break;
+ String[] runtimeArgs = VM.getRuntimeArguments();
+ for (String arg : runtimeArgs) {
+ // Handle any supported runtime options; ignore all others.
+ // The runtime arguments always use the single token form, e.g. "--name=value".
+ for (Option o : getSupportedRuntimeOptions()) {
+ if (o.matches(arg)) {
+ switch (o) {
+ case ADD_MODULES:
+ int eq = arg.indexOf('=');
+ Assert.check(eq > 0, () -> ("invalid runtime option:" + arg));
+ // --add-modules=ALL-DEFAULT is not supported at compile-time
+ // so remove it from list, and only process the rest
+ // if the set is non-empty.
+ // Note that --add-modules=ALL-DEFAULT is automatically added
+ // by the standard javac launcher.
+ String mods = Arrays.stream(arg.substring(eq + 1).split(","))
+ .filter(s -> !s.isEmpty() && !s.equals("ALL-DEFAULT"))
+ .collect(Collectors.joining(","));
+ if (!mods.isEmpty()) {
+ String updatedArg = arg.substring(0, eq + 1) + mods;
+ o.handleOption(helper, updatedArg, Collections.emptyIterator());
+ }
+ break;
+ default:
+ o.handleOption(helper, arg, Collections.emptyIterator());
+ break;
}
+ break;
}
}
- } catch (ClassNotFoundException | SecurityException e) {
- throw helper.newInvalidValueException("err.cannot.access.runtime.env");
}
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java
index a723d811ed5..c410067db8c 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java
@@ -712,20 +712,20 @@ public class JavacFiler implements Filer, Closeable {
}
private void checkNameAndExistence(ModuleSymbol mod, String typename, boolean allowUnnamedPackageInfo) throws FilerException {
- // TODO: Check if type already exists on source or class path?
- // If so, use warning message key proc.type.already.exists
checkName(typename, allowUnnamedPackageInfo);
- ClassSymbol existing;
+ ClassSymbol existing = elementUtils.getTypeElement(typename);
boolean alreadySeen = aggregateGeneratedSourceNames.contains(Pair.of(mod, typename)) ||
aggregateGeneratedClassNames.contains(Pair.of(mod, typename)) ||
initialClassNames.contains(typename) ||
- ((existing = elementUtils.getTypeElement(typename)) != null &&
- initialInputs.contains(existing.sourcefile));
+ (existing != null && initialInputs.contains(existing.sourcefile));
if (alreadySeen) {
if (lint)
log.warning(Warnings.ProcTypeRecreate(typename));
throw new FilerException("Attempt to recreate a file for type " + typename);
}
+ if (lint && existing != null) {
+ log.warning("proc.type.already.exists", typename);
+ }
if (!mod.isUnnamed() && !typename.contains(".")) {
throw new FilerException("Attempt to create a type in unnamed package of a named module: " + typename);
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
index 0bd0b3fc196..58d8d3df0ee 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -82,7 +82,6 @@ import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.Iterators;
import com.sun.tools.javac.util.JCDiagnostic;
-import com.sun.tools.javac.util.JDK9Wrappers.Module;
import com.sun.tools.javac.util.JavacMessages;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Log;
@@ -267,7 +266,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
: fileManager.getClassLoader(CLASS_PATH);
if (options.isSet("accessInternalAPI"))
- ModuleHelper.addExports(Module.getModule(getClass()), Module.getUnnamedModule(processorClassLoader));
+ ModuleHelper.addExports(getClass().getModule(), processorClassLoader.getUnnamedModule());
if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader);
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
index ecfc372fa6b..df339a0b150 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
@@ -55,7 +55,7 @@ import com.sun.tools.javac.util.StringUtils;
* deletion without notice.
*/
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_10)
+@SupportedSourceVersion(SourceVersion.RELEASE_11)
public class PrintingProcessor extends AbstractProcessor {
PrintWriter writer;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
index a8052159762..d4f3b1f08c7 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
@@ -443,6 +443,10 @@ compiler.err.invalid.repeatable.annotation.not.applicable.in.context=\
compiler.err.duplicate.class=\
duplicate class: {0}
+# 0: name, 1: name
+compiler.err.same.binary.name=\
+ classes: {0} and {1} have the same binary name
+
compiler.err.duplicate.case.label=\
duplicate case label
@@ -1140,16 +1144,21 @@ compiler.err.type.var.more.than.once=\
compiler.err.type.var.more.than.once.in.result=\
type variable {0} occurs more than once in type of {1}; cannot be left uninstantiated
-# 0: type, 1: type, 2: string
-compiler.err.types.incompatible.diff.ret=\
- types {0} and {1} are incompatible; both define {2}, but with unrelated return types
+# 0: type, 1: type, 2: fragment
+compiler.err.types.incompatible=\
+ types {0} and {1} are incompatible;\n\
+ {2}
+
+# 0: name, 1: list of type
+compiler.misc.incompatible.diff.ret=\
+ both define {0}({1}), but with unrelated return types
# 0: kind name, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
-compiler.err.types.incompatible.unrelated.defaults=\
+compiler.misc.incompatible.unrelated.defaults=\
{0} {1} inherits unrelated defaults for {2}({3}) from types {4} and {5}
# 0: kind name, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
-compiler.err.types.incompatible.abstract.default=\
+compiler.misc.incompatible.abstract.default=\
{0} {1} inherits abstract and default for {2}({3}) from types {4} and {5}
# 0: name, 1: kind name, 2: symbol
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
index 800ce92ee48..67e77e3bd16 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2018, 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
@@ -374,8 +374,6 @@ javac.err.file.not.directory=\
not a directory: {0}
javac.err.file.not.file=\
not a file: {0}
-javac.err.cannot.access.runtime.env=\
- cannot access runtime environment
javac.err.two.class.loaders.1=\
javac is split between multiple class loaders: check your configuration
javac.err.two.class.loaders.2=\
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java
deleted file mode 100644
index 40b8f249b8f..00000000000
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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 com.sun.tools.javac.util;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.ServiceLoader;
-
-/**
- * This class provides wrappers for classes and methods that are new in JDK 9, and which are not
- * available on older versions of the platform on which javac may be compiled and run.
- * In future releases, when javac is always compiled on JDK 9 or later, the use of these wrappers
- * can be replaced by use of the real underlying classes.
- *
- *
Wrapper classes provide a subset of the API of the wrapped classes, as needed for use
- * in javac. Wrapper objects contain an {@code Object} reference to the underlying runtime object,
- * and {@code Class} and {@code Method} objects for obtaining or using such instances via
- * runtime reflection. The {@code Class} and {@code Method} objects are set up on a per-class
- * basis, by an {@code init} method, which is called from static methods on the wrapper class,
- * or in the constructor, when instances are created.
- *
- *
- *
This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.
- */
-public class JDK9Wrappers {
-
- /**
- * Helper class for new method in java.util.ServiceLoader.
- */
- public static final class ServiceLoaderHelper {
- @SuppressWarnings("unchecked")
- public static ServiceLoader load(Layer layer, Class service) {
- try {
- init();
- Object result = loadMethod.invoke(null, layer.theRealLayer, service);
- return (ServiceLoader)result;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- // -----------------------------------------------------------------------------------------
-
- private static Method loadMethod = null;
-
- private static void init() {
- if (loadMethod == null) {
- try {
- Class> layerClass = Layer.layerClass;
- loadMethod = ServiceLoader.class.getDeclaredMethod("load", layerClass, Class.class);
- } catch (NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
-
- /**
- * Wrapper class for java.lang.module.ModuleDescriptor and ModuleDescriptor.Version.
- */
- public static class ModuleDescriptor {
- public static class Version {
- public static final String CLASSNAME = "java.lang.module.ModuleDescriptor$Version";
- private final Object theRealVersion;
-
- private Version(Object version) {
- this.theRealVersion = version;
- }
-
- public static Version parse(String v) {
- try {
- init();
- Object result = parseMethod.invoke(null, v);
- Version version = new Version(result);
- return version;
- } catch (InvocationTargetException ex) {
- if (ex.getCause() instanceof IllegalArgumentException) {
- throw (IllegalArgumentException) ex.getCause();
- } else {
- throw new Abort(ex);
- }
- } catch (IllegalAccessException | IllegalArgumentException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- @Override
- public String toString() {
- return theRealVersion.toString();
- }
-
- // -----------------------------------------------------------------------------------------
-
- private static Class> versionClass = null;
- private static Method parseMethod = null;
-
- private static void init() {
- if (versionClass == null) {
- try {
- versionClass = Class.forName(CLASSNAME, false, null);
- parseMethod = versionClass.getDeclaredMethod("parse", String.class);
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
- }
-
- /**
- * Wrapper class for java.lang.module.ModuleFinder.
- */
- public static class ModuleFinder {
- private final Object theRealModuleFinder;
-
- private ModuleFinder(Object moduleFinder) {
- this.theRealModuleFinder = moduleFinder;
- init();
- }
-
- public static ModuleFinder of(Path... dirs) {
- try {
- init();
- Object result = ofMethod.invoke(null, (Object)dirs);
- ModuleFinder mFinder = new ModuleFinder(result);
- return mFinder;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- // -----------------------------------------------------------------------------------------
-
- private static Class> moduleFinderClass = null;
- private static Method ofMethod;
-
- static final Class> getModuleFinderClass() {
- init();
- return moduleFinderClass;
- }
-
- private static void init() {
- if (moduleFinderClass == null) {
- try {
- moduleFinderClass = Class.forName("java.lang.module.ModuleFinder", false, null);
- ofMethod = moduleFinderClass.getDeclaredMethod("of", Path[].class);
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
-
- /**
- * Wrapper class for java.lang.Module. To materialize a handle use the static factory
- * methods Module#getModule(Class>) or Module#getUnnamedModule(ClassLoader).
- */
- public static class Module {
-
- private final Object theRealModule;
-
- private Module(Object module) {
- this.theRealModule = module;
- init();
- }
-
- public static Module getModule(Class> clazz) {
- try {
- init();
- Object result = getModuleMethod.invoke(clazz, new Object[0]);
- return new Module(result);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- public static Module getUnnamedModule(ClassLoader classLoader) {
- try {
- init();
- Object result = getUnnamedModuleMethod.invoke(classLoader, new Object[0]);
- return new Module(result);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- public Module addExports(String pn, Module other) {
- try {
- addExportsMethod.invoke(theRealModule, new Object[] { pn, other.theRealModule});
- } catch (IllegalAccessException | InvocationTargetException ex) {
- throw new Abort(ex);
- }
- return this;
- }
-
- public Module addUses(Class> st) {
- try {
- addUsesMethod.invoke(theRealModule, new Object[] { st });
- } catch (IllegalAccessException | InvocationTargetException ex) {
- throw new Abort(ex);
- }
- return this;
- }
-
- // -----------------------------------------------------------------------------------------
- // on java.lang.Module
- private static Method addExportsMethod = null;
- // on java.lang.Module
- private static Method addUsesMethod = null;
- // on java.lang.Class
- private static Method getModuleMethod;
- // on java.lang.ClassLoader
- private static Method getUnnamedModuleMethod;
-
- private static void init() {
- if (addExportsMethod == null) {
- try {
- Class> moduleClass = Class.forName("java.lang.Module", false, null);
- addUsesMethod = moduleClass.getDeclaredMethod("addUses", new Class>[] { Class.class });
- addExportsMethod = moduleClass.getDeclaredMethod("addExports",
- new Class>[] { String.class, moduleClass });
- getModuleMethod = Class.class.getDeclaredMethod("getModule", new Class>[0]);
- getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule", new Class>[0]);
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
-
- /**
- * Wrapper class for java.lang.module.Configuration.
- */
- public static final class Configuration {
- private final Object theRealConfiguration;
-
- private Configuration(Object configuration) {
- this.theRealConfiguration = configuration;
- init();
- }
-
- public Configuration resolveAndBind(
- ModuleFinder beforeFinder,
- ModuleFinder afterFinder,
- Collection roots) {
- try {
- Object result = resolveAndBindMethod.invoke(theRealConfiguration,
- beforeFinder.theRealModuleFinder,
- afterFinder.theRealModuleFinder,
- roots
- );
- Configuration configuration = new Configuration(result);
- return configuration;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- // -----------------------------------------------------------------------------------------
-
- private static Class> configurationClass = null;
- private static Method resolveAndBindMethod;
-
- static final Class> getConfigurationClass() {
- init();
- return configurationClass;
- }
-
- private static void init() {
- if (configurationClass == null) {
- try {
- configurationClass = Class.forName("java.lang.module.Configuration", false, null);
- Class> moduleFinderInterface = ModuleFinder.getModuleFinderClass();
- resolveAndBindMethod = configurationClass.getDeclaredMethod("resolveAndBind",
- moduleFinderInterface,
- moduleFinderInterface,
- Collection.class
- );
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
-
- /**
- * Wrapper class for java.lang.ModuleLayer.
- */
- public static final class Layer {
- private final Object theRealLayer;
-
- private Layer(Object layer) {
- this.theRealLayer = layer;
- }
-
- public static Layer boot() {
- try {
- init();
- Object result = bootMethod.invoke(null);
- Layer layer = new Layer(result);
- return layer;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- public Configuration configuration() {
- try {
- Object result = configurationMethod.invoke(theRealLayer);
- Configuration configuration = new Configuration(result);
- return configuration;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- public Layer defineModulesWithOneLoader(Configuration configuration, ClassLoader parentClassLoader) {
- try {
- Object result = defineModulesWithOneLoaderMethod.invoke(
- theRealLayer, configuration.theRealConfiguration, parentClassLoader);
- Layer layer = new Layer(result);
- return layer;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- // -----------------------------------------------------------------------------------------
-
- private static Class> layerClass = null;
- private static Method bootMethod;
- private static Method defineModulesWithOneLoaderMethod;
- private static Method configurationMethod;
-
- private static void init() {
- if (layerClass == null) {
- try {
- layerClass = Class.forName("java.lang.ModuleLayer", false, null);
- bootMethod = layerClass.getDeclaredMethod("boot");
- defineModulesWithOneLoaderMethod = layerClass.getDeclaredMethod("defineModulesWithOneLoader",
- Configuration.getConfigurationClass(),
- ClassLoader.class);
- configurationMethod = layerClass.getDeclaredMethod("configuration");
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
-
-
- /**
- * Helper class for new method in jdk.internal.misc.VM.
- */
- public static final class VMHelper {
- public static final String CLASSNAME = "jdk.internal.misc.VM";
-
- @SuppressWarnings("unchecked")
- public static String[] getRuntimeArguments() {
- try {
- init();
- Object result = getRuntimeArgumentsMethod.invoke(null);
- return (String[])result;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- // -----------------------------------------------------------------------------------------
-
- private static Class> vmClass = null;
- private static Method getRuntimeArgumentsMethod = null;
-
- private static void init() {
- if (vmClass == null) {
- try {
- vmClass = Class.forName(CLASSNAME, false, null);
- getRuntimeArgumentsMethod = vmClass.getDeclaredMethod("getRuntimeArguments");
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
-
- /**
- * Helper class for new method in jdk.internal.jmod.JmodFile
- */
- public static final class JmodFile {
- public static final String JMOD_FILE_CLASSNAME = "jdk.internal.jmod.JmodFile";
-
- public static void checkMagic(Path file) throws IOException {
- try {
- init();
- checkMagicMethod.invoke(null, file);
- } catch (InvocationTargetException ex) {
- if (ex.getCause() instanceof IOException) {
- throw IOException.class.cast(ex.getCause());
- }
- throw new Abort(ex);
- } catch (IllegalAccessException | IllegalArgumentException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
-
- // -----------------------------------------------------------------------------------------
-
- private static Class> jmodFileClass = null;
- private static Method checkMagicMethod = null;
-
- private static void init() {
- if (jmodFileClass == null) {
- try {
- jmodFileClass = Class.forName(JMOD_FILE_CLASSNAME, false, null);
- checkMagicMethod = jmodFileClass.getDeclaredMethod("checkMagic", Path.class);
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
- throw new Abort(ex);
- }
- }
- }
- }
-}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java
index 906c0ccf85b..90ed55ad9b3 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -25,8 +25,6 @@
package com.sun.tools.javac.util;
-import com.sun.tools.javac.util.JDK9Wrappers.Module;
-
public class ModuleHelper {
private static final String[] javacInternalPackages = new String[] {
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java
index bdc74fb15dc..48cacb64383 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -46,8 +46,8 @@ public class Classfile {
private final ResolvedJavaType type;
private final List codeAttributes;
- private static final int MAJOR_VERSION_JAVA7 = 51;
- private static final int MAJOR_VERSION_JAVA10 = 54;
+ private static final int MAJOR_VERSION_JAVA_MIN = 51;
+ private static final int MAJOR_VERSION_JAVA_MAX = 55;
private static final int MAGIC = 0xCAFEBABE;
/**
@@ -65,7 +65,7 @@ public class Classfile {
int minor = stream.readUnsignedShort();
int major = stream.readUnsignedShort();
- if (major < MAJOR_VERSION_JAVA7 || major > MAJOR_VERSION_JAVA10) {
+ if (major < MAJOR_VERSION_JAVA_MIN || major > MAJOR_VERSION_JAVA_MAX) {
throw new UnsupportedClassVersionError("Unsupported class file version: " + major + "." + minor);
}
diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java
index 8f0c761d6cf..9cac709031f 100644
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java
@@ -50,7 +50,7 @@ import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
-import static javax.lang.model.SourceVersion.RELEASE_10;
+import static javax.lang.model.SourceVersion.RELEASE_11;
/**
* Annotation processor for the Deprecation Scanner tool.
@@ -58,7 +58,7 @@ import static javax.lang.model.SourceVersion.RELEASE_10;
*
*/
@SupportedAnnotationTypes("java.lang.Deprecated")
-@SupportedSourceVersion(RELEASE_10)
+@SupportedSourceVersion(RELEASE_11)
public class LoadProc extends AbstractProcessor {
Elements elements;
Messager messager;
diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java
index 7dfbb31499a..115075264fd 100644
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java
@@ -106,7 +106,7 @@ public class Main implements DiagnosticListener {
// Keep these updated manually until there's a compiler API
// that allows querying of supported releases.
final Set releasesWithoutForRemoval = Set.of("6", "7", "8");
- final Set releasesWithForRemoval = Set.of("9", "10");
+ final Set releasesWithForRemoval = Set.of("9", "10", "11");
final Set validReleases;
{
@@ -358,14 +358,15 @@ public class Main implements DiagnosticListener {
* Process classes from a particular JDK release, using only information
* in this JDK.
*
- * @param release "6", "7", "8", "9", or "10"
+ * @param release "6", "7", "8", "9", "10", or "11"
* @param classes collection of classes to process, may be empty
* @return success value
*/
boolean processRelease(String release, Collection classes) throws IOException {
options.addAll(List.of("--release", release));
- if (release.equals("9") || release.equals("10")) {
+ if (release.equals("9") || release.equals("10") ||
+ release.equals("11")) {
List rootMods = List.of("java.se", "java.se.ee");
TraverseProc proc = new TraverseProc(rootMods);
JavaCompiler.CompilationTask task =
@@ -481,7 +482,7 @@ public class Main implements DiagnosticListener {
String dir = null;
String jar = null;
String jdkHome = null;
- String release = "10";
+ String release = "11";
List loadClasses = new ArrayList<>();
String csvFile = null;
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java b/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java
index 85b903d670a..8216220d5d8 100644
--- a/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java
+++ b/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java
@@ -67,7 +67,7 @@ public interface RuntimeConstants {
/* Class File Constants */
int JAVA_MAGIC = 0xcafebabe;
int JAVA_MIN_SUPPORTED_VERSION = 45;
- int JAVA_MAX_SUPPORTED_VERSION = 54;
+ int JAVA_MAX_SUPPORTED_VERSION = 55;
int JAVA_MAX_SUPPORTED_MINOR_VERSION = 0;
/* Generate class file version for 1.1 by default */
diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt
index d56bd6c0a14..03b8ef8eafa 100644
--- a/test/hotspot/jtreg/ProblemList.txt
+++ b/test/hotspot/jtreg/ProblemList.txt
@@ -42,6 +42,7 @@
compiler/ciReplay/TestSAServer.java 8029528 generic-all
compiler/codecache/stress/OverloadCompileQueueTest.java 8166554 generic-all
+compiler/codegen/Test6896617.java 8193479 generic-all
compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java 8140405 generic-all
compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java 8158860 generic-all
compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java 8163894 generic-all
@@ -50,6 +51,7 @@ compiler/startup/SmallCodeCacheStartup.java 8134286 generic-all
compiler/tiered/LevelTransitionTest.java 8067651 generic-all
compiler/types/correctness/CorrectnessTest.java 8066173 generic-all
compiler/types/correctness/OffTest.java 8066173 generic-all
+compiler/c2/Test8007294.java 8192992 generic-all
# aot test intermittently failing in jprt 8175791
compiler/aot/DeoptimizationTest.java 8175791 windows-all
diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT
index c7ccaf2f4de..651ebdf6849 100644
--- a/test/hotspot/jtreg/TEST.ROOT
+++ b/test/hotspot/jtreg/TEST.ROOT
@@ -58,7 +58,7 @@ requires.properties= \
docker.support
# Minimum jtreg version
-requiredVersion=4.2 b08
+requiredVersion=4.2 b11
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../../ notation to reach them
diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
index bedcad2e4fe..70d6a636721 100644
--- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
+++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
@@ -47,10 +47,6 @@ public class VMDeprecatedOptions {
{"InitialRAMFraction", "64"},
{"AssumeMP", "false"},
{"UseMembar", "true"},
- {"FastTLABRefill", "false"},
- {"DeferPollingPageLoopCount", "-1"},
- {"SafepointSpinBeforeYield", "2000"},
- {"DeferThrSuspendLoopCount", "4000"},
// deprecated alias flags (see also aliased_jvm_flags):
{"DefaultMaxRAMFraction", "4"},
@@ -110,6 +106,5 @@ public class VMDeprecatedOptions {
testDeprecated(DEPRECATED_OPTIONS); // Make sure that each deprecated option is mentioned in the output.
testDeprecatedDiagnostic("UnsyncloadClass", "false");
testDeprecatedDiagnostic("IgnoreUnverifiableClassesDuringDump", "false");
- testDeprecatedExperimental("UseCGroupMemoryLimitForHeap", "true");
}
}
diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/Class55.jasm b/test/hotspot/jtreg/runtime/classFileParserBug/Class55.jasm
new file mode 100644
index 00000000000..42af9b3206c
--- /dev/null
+++ b/test/hotspot/jtreg/runtime/classFileParserBug/Class55.jasm
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 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.
+ *
+ * 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
+ * @bug 8173382
+ * @summary Check that the JVM accepts class files with version 55
+ * @run main Class55
+ */
+
+super public class Class55 version 55:0 {
+
+ public Method "":"()V" stack 1 locals 1 {
+ aload_0;
+ invokespecial Method java/lang/Object."":"()V";
+ return;
+ }
+
+ public static Method main:"([Ljava/lang/String;)V" stack 0 locals 1 {
+ return;
+ }
+
+} // end Class Class55
diff --git a/test/jaxp/TEST.ROOT b/test/jaxp/TEST.ROOT
index e2f049d3487..4bf95e20e90 100644
--- a/test/jaxp/TEST.ROOT
+++ b/test/jaxp/TEST.ROOT
@@ -23,7 +23,7 @@ modules=java.xml
groups=TEST.groups
# Minimum jtreg version
-requiredVersion=4.2 b08
+requiredVersion=4.2 b11
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them
diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT
index 7e9517b7c05..8a71067aa5c 100644
--- a/test/jdk/TEST.ROOT
+++ b/test/jdk/TEST.ROOT
@@ -40,7 +40,7 @@ requires.properties= \
vm.cds
# Minimum jtreg version
-requiredVersion=4.2 b09
+requiredVersion=4.2 b11
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them
diff --git a/test/jdk/java/io/InputStream/ReadAllBytes.java b/test/jdk/java/io/InputStream/ReadAllBytes.java
index c190cd2dd54..a9c536b1909 100644
--- a/test/jdk/java/io/InputStream/ReadAllBytes.java
+++ b/test/jdk/java/io/InputStream/ReadAllBytes.java
@@ -31,7 +31,7 @@ import jdk.test.lib.RandomFactory;
/*
* @test
- * @bug 8080835
+ * @bug 8080835 8193832
* @library /test/lib
* @build jdk.test.lib.RandomFactory
* @run main ReadAllBytes
@@ -47,15 +47,11 @@ public class ReadAllBytes {
test(new byte[]{});
test(new byte[]{1, 2, 3});
test(createRandomBytes(1024));
- test(createRandomBytes((1 << 13) - 1));
- test(createRandomBytes((1 << 13)));
- test(createRandomBytes((1 << 13) + 1));
- test(createRandomBytes((1 << 15) - 1));
- test(createRandomBytes((1 << 15)));
- test(createRandomBytes((1 << 15) + 1));
- test(createRandomBytes((1 << 17) - 1));
- test(createRandomBytes((1 << 17)));
- test(createRandomBytes((1 << 17) + 1));
+ for (int shift : new int[] {13, 14, 15, 17}) {
+ for (int offset : new int[] {-1, 0, 1}) {
+ test(createRandomBytes((1 << shift) + offset));
+ }
+ }
}
static void test(byte[] expectedBytes) throws IOException {
diff --git a/test/jdk/java/lang/module/ClassFileVersionsTest.java b/test/jdk/java/lang/module/ClassFileVersionsTest.java
index c7808adb223..e5a74e30a38 100644
--- a/test/jdk/java/lang/module/ClassFileVersionsTest.java
+++ b/test/jdk/java/lang/module/ClassFileVersionsTest.java
@@ -54,6 +54,8 @@ public class ClassFileVersionsTest {
{ 53, 0, Set.of(STATIC, TRANSITIVE) },
{ 54, 0, Set.of() }, // JDK 10
+
+ { 55, 0, Set.of()}, // JDK 11
};
}
@@ -69,7 +71,11 @@ public class ClassFileVersionsTest {
{ 54, 0, Set.of(TRANSITIVE) },
{ 54, 0, Set.of(STATIC, TRANSITIVE) },
- { 55, 0, Set.of()}, // JDK 11
+ { 55, 0, Set.of(STATIC) }, // JDK 11
+ { 55, 0, Set.of(TRANSITIVE) },
+ { 55, 0, Set.of(STATIC, TRANSITIVE) },
+
+ { 56, 0, Set.of()}, // JDK 12
};
}
diff --git a/test/jdk/java/lang/ref/ReferenceEnqueue.java b/test/jdk/java/lang/ref/ReferenceEnqueue.java
index ddc89fc7f27..c405c5c8a05 100644
--- a/test/jdk/java/lang/ref/ReferenceEnqueue.java
+++ b/test/jdk/java/lang/ref/ReferenceEnqueue.java
@@ -25,7 +25,6 @@
* @bug 4268317 8132306 8175797
* @summary Test if Reference.enqueue() works properly with GC
* @run main ReferenceEnqueue
- * @run main/othervm -Djdk.lang.ref.disableClearBeforeEnqueue=true ReferenceEnqueue
*/
import java.lang.ref.*;
@@ -87,8 +86,6 @@ public class ReferenceEnqueue {
final ReferenceQueue