diff --git a/README.md b/README.md index 8a0c45b5a94..7417dbbb206 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ sponsored by the Eclipse Foundation. ### Compatibility -* Eclipse GlassFish 7.0.0 is Jakarta EE 10 compatible, requires Java 11, supports Java 17 and Java 21 +* Eclipse GlassFish 7.0.0 is Jakarta EE 10 compatible, requires Java 11, supports Java 17 and Java 21, experimentally also higher versions. * Eclipse GlassFish 6.2.0 is Jakarta EE 9.1 compatible, requires Java 11, supports Java 17 * Eclipse GlassFish 6.1.0 is Jakarta EE 9.1 compatible, requires Java 11 * Eclipse GlassFish 6.0.0 is Jakarta EE 9 compatible, requires Java 8 diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java index 65e78db2f91..b7c556eff58 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -20,7 +20,6 @@ import com.sun.enterprise.container.common.spi.util.InjectionException; import com.sun.enterprise.deployment.node.SaxParserHandlerBundled; import com.sun.enterprise.universal.glassfish.TokenResolver; -import com.sun.enterprise.util.JDK; import com.sun.enterprise.util.LocalStringManager; import com.sun.enterprise.util.LocalStringManagerImpl; @@ -148,14 +147,11 @@ public static void launch(String[] args) throws NoSuchMethodException, ClassNotF public static void prepareACC(String agentArgsText, Instrumentation inst) throws UserError, MalformedURLException, URISyntaxException, JAXBException, FileNotFoundException, ParserConfigurationException, SAXException, IOException, Exception { - int minor = JDK.getMinor(); - int major = JDK.getMajor(); - if (major < 9) { - if (minor < 6) { - throw new UserError(localStrings.getLocalString(stringsAnchor, "main.badVersion", - "Current Java version {0} is too low; {1} or later required", - new Object[] { System.getProperty("java.version"), "1.6" })); - } + int version = Runtime.version().feature(); + if (version < 11) { + throw new UserError(localStrings.getLocalString(stringsAnchor, "main.badVersion", + "Current Java version {0} is too low; {1} or later required", + new Object[] {System.getProperty("java.version"), "11"})); } /* diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/StaticRmiStubGenerator.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/StaticRmiStubGenerator.java index 899b7ad506d..b30c523c9e5 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/StaticRmiStubGenerator.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/StaticRmiStubGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -22,7 +22,6 @@ import com.sun.enterprise.deployment.EjbBundleDescriptor; import com.sun.enterprise.deployment.EjbDescriptor; import com.sun.enterprise.deployment.util.TypeUtil; -import com.sun.enterprise.util.JDK; import com.sun.enterprise.util.OS; import com.sun.enterprise.util.i18n.StringManager; import com.sun.logging.LogDomains; @@ -250,7 +249,7 @@ private void rmic(String classPath, Set stubClasses, File destDir, return; } - if( toolsJarPath == null && !OS.isDarwin() && JDK.getMajor() < 9) { + if( toolsJarPath == null && !OS.isDarwin() && Runtime.version().feature() < 11) { _logger.log(Level.INFO, "[RMIC] tools.jar location was not found"); return; } diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java index 7c3ceb8829c..ee6eb6d88fa 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -22,11 +22,11 @@ import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; -import com.sun.enterprise.util.JDK; import com.sun.enterprise.util.SystemPropertyConstants; import java.io.File; import java.io.PrintStream; +import java.lang.Runtime.Version; import java.net.ConnectException; import java.security.AccessController; import java.security.PrivilegedAction; @@ -215,10 +215,9 @@ public static void main(String[] args) { } protected int doMain(String[] args) { - int minor = JDK.getMinor(); - int major = JDK.getMajor(); - if (major < 11) { - System.err.println(strings.get("OldJdk", major, minor)); + Version version = Runtime.version(); + if (version.feature() < 11) { + System.err.println(strings.get("OldJdk", 11, version)); return ERROR; } diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LocalStrings.properties b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LocalStrings.properties index ee37b2b002a..a78ac4ee1ec 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LocalStrings.properties +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LocalStrings.properties @@ -167,7 +167,7 @@ badEnvVarUnset=CLI163: Could not unset environment variable: {0}\nVariable names cantRemoveEnvVar=CLI149: Environment variable is not set: {0} operandPrompt=Enter the value for the {0} operand>\u0020 optionPrompt=Enter the value for the {0} option>\u0020 -OldJdk=GlassFish requires Java SE version 8. Your JDK is version {0} +OldJdk=GlassFish requires Java SE version {0}. Your JDK is version {1}. DeprecatedSyntax=Deprecated syntax, instead use: ## Parser parser.noValueAllowed=Option may not have value: {0} diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/JDK.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/JDK.java deleted file mode 100644 index d7ddd796931..00000000000 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/JDK.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.enterprise.util; - -/** - * A simple class that fills a hole in the JDK. It parses out the version numbers - * of the JDK we are running. - * Example:

- * 1.6.0_u14 == major = 1 minor = 6, subminor = 0, update = 14 - * - * @author bnevins - */ -public final class JDK { - - private JDK(String string) { - String[] split = string.split("[\\._\\-]+"); - - if (split.length > 0) { - major = Integer.parseInt(split[0]); - } - if (split.length > 1) { - minor = Integer.parseInt(split[1]); - } - if (split.length > 2) { - subminor = Integer.parseInt(split[2]); - } - if (split.length > 3) { - update = Integer.parseInt(split[3]); - } - } - - - public static JDK getVersion(String string) { - if (string.matches("([0-9]+[\\._\\-]+)*[0-9]+")) { - return new JDK(string); - } else { - return null; - } - } - /** - * See if the current JDK is legal for running GlassFish - * @return true if the JDK is >= 1.6.0 - */ - public static boolean ok() { - return major == 1 && minor >= 6; - } - - public static int getMajor() { - return major; - } - public static int getMinor() { - return minor; - } - - public static int getSubMinor() { - return subminor; - } - - public static int getUpdate() { - return update; - } - - public boolean newerThan(JDK version) { - if (major > version.getMajor()) { - return true; - } else if (major == version.getMajor()) { - if (minor > version.getMinor()) { - return true; - } else if (minor == version.getMinor()) { - if (subminor > version.getSubMinor()) { - return true; - } else if (subminor == version.getSubMinor()) { - if (update > version.getUpdate()) { - return true; - } - } - } - } - - return false; - } - - public boolean newerOrEquals(JDK version) { - return newerThan(version) || equals(version); - } - - public boolean olderThan(JDK version) { - return !newerOrEquals(version); - } - - public boolean olderOrEquals(JDK version) { - return !newerThan(version); - } - - /** - * No instances are allowed so it is pointless to override toString - * @return Parsed version numbers - */ - public static String toStringStatic() { - return "major: " + JDK.getMajor() + - "\nminor: " + JDK.getMinor() + - "\nsubminor: " + JDK.getSubMinor() + - "\nupdate: " + JDK.getUpdate() + - "\nOK ==>" + JDK.ok(); - } - - static { - initialize(); - } - - // DO NOT initialize these variables. You'll be sorry if you do! - private static int major; - private static int minor; - private static int subminor; - private static int update; - - // silently fall back to ridiculous defaults if something is crazily wrong... - private static void initialize() { - major = 1; - minor = subminor = update = 0; - try { - String jv = System.getProperty("java.version"); - /*In JEP 223 java.specification.version will be a single number versioning , not a dotted versioning . So if we get a single - integer as versioning we know that the JDK is post JEP 223 - For JDK 8: - java.specification.version 1.8 - java.version 1.8.0_122 - For JDK 9: - java.specification.version 9 - java.version 9.1.2 - */ - String javaSpecificationVersion = System.getProperty("java.specification.version"); - String[] jsvSplit = javaSpecificationVersion.split("\\."); - if (jsvSplit.length == 1) { - //This is handle Early Access build .Example 9-ea - String[] jvSplit = jv.split("-"); - String jvReal = jvSplit[0]; - String[] split = jvReal.split("[\\.]+"); - - if (split.length > 0) { - if (split.length > 0) { - major = Integer.parseInt(split[0]); - } - if (split.length > 1) { - minor = Integer.parseInt(split[1]); - } - if (split.length > 2) { - subminor = Integer.parseInt(split[2]); - } - if (split.length > 3) { - update = Integer.parseInt(split[3]); - } - } - } else { - if (!StringUtils.ok(jv)) - return; // not likely!! - - String[] ss = jv.split("\\."); - - if (ss.length < 3 || !ss[0].equals("1")) - return; - - major = Integer.parseInt(ss[0]); - minor = Integer.parseInt(ss[1]); - ss = ss[2].split("_"); - - if (ss.length < 1) - return; - - subminor = Integer.parseInt(ss[0]); - - if (ss.length > 1) - update = Integer.parseInt(ss[1]); - } - } - catch(Exception e) { - // ignore -- use defaults - } - } -} diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java index 4921943a925..691b5fa6cb1 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -67,22 +67,13 @@ public class MainHelper { static void checkJdkVersion() { - int major = getMajorJdkVersion(); - if (major < 11) { - BOOTSTRAP_LOGGER.log(SEVERE, LogFacade.BOOTSTRAP_INCORRECT_JDKVERSION, new Object[] {11, major}); + int version = Runtime.version().feature(); + if (version < 11) { + BOOTSTRAP_LOGGER.log(SEVERE, LogFacade.BOOTSTRAP_INCORRECT_JDKVERSION, new Object[] {11, version}); System.exit(1); } } - private static int getMajorJdkVersion() { - String jv = System.getProperty("java.version"); - String[] split = jv.split("[\\._\\-]+"); - if (split.length > 0) { - return Integer.parseInt(split[0]); - } - return -1; - } - static String whichPlatform() { final String platformSysOption = System.getProperty(PLATFORM_PROPERTY_KEY); if (platformSysOption != null && !platformSysOption.isBlank()) { diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties b/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties index d8bb7ce6664..0cb1c791cdc 100755 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation +# Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2018 The Apache Software Foundation # @@ -204,6 +204,14 @@ gosh.args=--nointeractive # Generic execution environment capabilities. org.osgi.framework.system.capabilities=${eecap-${java.vm.specification.version}} +eecap-23= \ + osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0,1.1,1.2", \ + osgi.ee; osgi.ee="JavaSE"; version:List="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23", \ + osgi.ee; osgi.ee="UNKNOWN" +eecap-22= \ + osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0,1.1,1.2", \ + osgi.ee; osgi.ee="JavaSE"; version:List="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,9,10,11,12,13,14,15,16,17,18,19,20,21,22", \ + osgi.ee; osgi.ee="UNKNOWN" eecap-21= \ osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0,1.1,1.2", \ osgi.ee; osgi.ee="JavaSE"; version:List="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,9,10,11,12,13,14,15,16,17,18,19,20,21", \ diff --git a/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties b/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties index d8bb7ce6664..0cb1c791cdc 100755 --- a/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties +++ b/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation +# Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2018 The Apache Software Foundation # @@ -204,6 +204,14 @@ gosh.args=--nointeractive # Generic execution environment capabilities. org.osgi.framework.system.capabilities=${eecap-${java.vm.specification.version}} +eecap-23= \ + osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0,1.1,1.2", \ + osgi.ee; osgi.ee="JavaSE"; version:List="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23", \ + osgi.ee; osgi.ee="UNKNOWN" +eecap-22= \ + osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0,1.1,1.2", \ + osgi.ee; osgi.ee="JavaSE"; version:List="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,9,10,11,12,13,14,15,16,17,18,19,20,21,22", \ + osgi.ee; osgi.ee="UNKNOWN" eecap-21= \ osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0,1.1,1.2", \ osgi.ee; osgi.ee="JavaSE"; version:List="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,9,10,11,12,13,14,15,16,17,18,19,20,21", \