Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental support of JDK23 and 22 for GlassFish 7 #25092

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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"}));
}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -250,7 +249,7 @@ private void rmic(String classPath, Set<String> 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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Copy link
Contributor

@pzygielo pzygielo Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering - how this can be entered and "OldJdk" used, given

com/sun/enterprise/admin/cli/AdminMain.class: compiled Java class data, version 55.0 (Java SE 11)

and with 8, JVM of course refuses to start:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)

(But this is for another issue/PR, if ever.)

Copy link
Contributor Author

@dmatej dmatej Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was in cases when ie in jdk 1.6u22 or so oracle/sun added some features and gf needed them. I am not sure how dead this code is, but yeah, we can remove it and add it just when it would be required again.

System.err.println(strings.get("OldJdk", version.feature(), version.interim()));
dmatej marked this conversation as resolved.
Show resolved Hide resolved
return ERROR;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down Expand Up @@ -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<Version>="1.0,1.1,1.2", \
osgi.ee; osgi.ee="JavaSE"; version:List<Version>="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<Version>="1.0,1.1,1.2", \
osgi.ee; osgi.ee="JavaSE"; version:List<Version>="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<Version>="1.0,1.1,1.2", \
osgi.ee; osgi.ee="JavaSE"; version:List<Version>="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", \
Expand Down
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down Expand Up @@ -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<Version>="1.0,1.1,1.2", \
osgi.ee; osgi.ee="JavaSE"; version:List<Version>="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<Version>="1.0,1.1,1.2", \
osgi.ee; osgi.ee="JavaSE"; version:List<Version>="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<Version>="1.0,1.1,1.2", \
osgi.ee; osgi.ee="JavaSE"; version:List<Version>="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", \
Expand Down