This is an automated email from the ASF dual-hosted git repository. mbien pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new d55be1aff9 Update JDK runtime version requirement warning. new d0793acdbd Merge pull request #6054 from mbien/update-min-jdk-warning d55be1aff9 is described below commit d55be1aff900a81b22081f7699fd16ab04e42553 Author: Michael Bien <mbie...@gmail.com> AuthorDate: Thu Jun 8 02:26:12 2023 +0200 Update JDK runtime version requirement warning. - NetBeans requires JDK 11 to run - disable check for tests --- .github/workflows/main.yml | 5 +-- .../project/suite/BuildZipDistributionTest.java | 1 + .../nbjunit/src/org/netbeans/junit/NbTestCase.java | 1 + .../src/org/netbeans/junit/NbModuleSuiteTest.java | 1 + .../autoupdate/services/NewClustersRebootTest.java | 1 + .../src/org/netbeans/Bundle.properties | 7 ++-- platform/o.n.bootstrap/src/org/netbeans/Main.java | 47 +++++++++++++++------- 7 files changed, 42 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dea7036ff8..e76bde4e3e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1159,10 +1159,7 @@ jobs: - name: platform/uihandler run: ant $OPTS -Dvanilla.javac.exists=true -f platform/uihandler test - - - name: platform/o.n.bootstrap - run: ant $OPTS -Dvanilla.javac.exists=true -f platform/o.n.bootstrap test - + - name: Set up JDK 11 uses: actions/setup-java@v3 with: diff --git a/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/suite/BuildZipDistributionTest.java b/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/suite/BuildZipDistributionTest.java index 73eba807b4..3e0356e34c 100644 --- a/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/suite/BuildZipDistributionTest.java +++ b/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/suite/BuildZipDistributionTest.java @@ -233,6 +233,7 @@ public class BuildZipDistributionTest extends TestBase { assertTrue("file found: " + testf, testf.exists()); LinkedList<String> allArgs = new LinkedList<String>(Arrays.asList(args)); + allArgs.addFirst("-J-Dbootstrap.disableJDKCheck=true"); allArgs.addFirst("-J-Dnetbeans.mainclass=" + MainCallback.class.getName()); allArgs.addFirst(getWorkDirPath()); allArgs.addFirst("--userdir"); diff --git a/harness/nbjunit/src/org/netbeans/junit/NbTestCase.java b/harness/nbjunit/src/org/netbeans/junit/NbTestCase.java index db23be1bf9..ee467fc21b 100644 --- a/harness/nbjunit/src/org/netbeans/junit/NbTestCase.java +++ b/harness/nbjunit/src/org/netbeans/junit/NbTestCase.java @@ -79,6 +79,7 @@ import org.netbeans.junit.internal.NbModuleLogHandler; public abstract class NbTestCase extends TestCase implements NbTest { static { MethodOrder.initialize(); + System.setProperty("bootstrap.disableJDKCheck", "true"); } /** * active filter diff --git a/harness/nbjunit/test/unit/src/org/netbeans/junit/NbModuleSuiteTest.java b/harness/nbjunit/test/unit/src/org/netbeans/junit/NbModuleSuiteTest.java index 1e106e208a..c910b95d77 100644 --- a/harness/nbjunit/test/unit/src/org/netbeans/junit/NbModuleSuiteTest.java +++ b/harness/nbjunit/test/unit/src/org/netbeans/junit/NbModuleSuiteTest.java @@ -59,6 +59,7 @@ public class NbModuleSuiteTest extends NbTestCase { assertEquals("Doesn't exist", System.getProperty("t.userdir")); assertProperty("netbeans.full.hack", "true"); + assertProperty("bootstrap.disableJDKCheck", "true"); } public void testPreparePatches() throws URISyntaxException { diff --git a/platform/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/NewClustersRebootTest.java b/platform/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/NewClustersRebootTest.java index cda8af5e67..f2e8f3f0dd 100644 --- a/platform/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/NewClustersRebootTest.java +++ b/platform/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/NewClustersRebootTest.java @@ -93,6 +93,7 @@ public class NewClustersRebootTest extends NbTestCase { assertTrue("file found: " + testf, testf.exists()); LinkedList<String> allArgs = new LinkedList<String>(Arrays.asList(args)); + allArgs.addFirst("-J-Dbootstrap.disableJDKCheck=true"); allArgs.addFirst("-J-Dnetbeans.mainclass=" + NewClustersRebootCallback.class.getName()); allArgs.addFirst(System.getProperty("java.home")); allArgs.addFirst("--jdkhome"); diff --git a/platform/o.n.bootstrap/src/org/netbeans/Bundle.properties b/platform/o.n.bootstrap/src/org/netbeans/Bundle.properties index 4f17fa9c14..e5de0ecec9 100644 --- a/platform/o.n.bootstrap/src/org/netbeans/Bundle.properties +++ b/platform/o.n.bootstrap/src/org/netbeans/Bundle.properties @@ -42,7 +42,8 @@ OpenIDE-Module-Long-Description=\ that loads all other parts of the application. \ It cannot be disabled. -MSG_InstallJava7=Cannot run on older versions of Java than Java 7 Standard Edition.\n\ - Please install Java 7 Standard Edition or newer or use --jdkhome\n\ +MSG_InstallJava=Cannot run on older versions of Java than Java {0}.\n\ + Please install Java {0} or newer or use --jdkhome\n\ switch to point to its installation directory. -MSG_NeedsJava7=Java 7 Standard Edition or newer required +MSG_NeedsJava=Java {0} or newer required +MSG_WarnJavaCheckDisabled=WARNING: JDK requirements check disabled diff --git a/platform/o.n.bootstrap/src/org/netbeans/Main.java b/platform/o.n.bootstrap/src/org/netbeans/Main.java index f89c1aad38..e15d779d1a 100644 --- a/platform/o.n.bootstrap/src/org/netbeans/Main.java +++ b/platform/o.n.bootstrap/src/org/netbeans/Main.java @@ -35,30 +35,49 @@ public final class Main extends Object { * @throws Exception for lots of reasons */ public static void main (String args[]) throws Exception { - // following code has to execute without java6 - e.g. do not use - // NbBundle or any other library compiled against java6 only - // also prevent usage of java6 methods and classes - try { - Class.forName("java.lang.ReflectiveOperationException"); // NOI18N - } catch (ClassNotFoundException ex) { - if (GraphicsEnvironment.isHeadless()) { - System.err.println(ResourceBundle.getBundle("org.netbeans.Bundle").getString("MSG_InstallJava7")); - } else { + // following code has to execute on java 8 - e.g. do not use + // NbBundle or any other library + int required = 11; + + if (Boolean.getBoolean("bootstrap.disableJDKCheck")) { + System.err.println(getMessage("MSG_WarnJavaCheckDisabled")); + } else if (!checkJavaVersion(required)) { + System.err.println(getMessage("MSG_InstallJava", required)); + if (!GraphicsEnvironment.isHeadless()) { JOptionPane.showMessageDialog( null, - ResourceBundle.getBundle("org.netbeans.Bundle").getString("MSG_InstallJava7"), - ResourceBundle.getBundle("org.netbeans.Bundle").getString("MSG_NeedsJava7"), + getMessage("MSG_InstallJava", required), + getMessage("MSG_NeedsJava", required), JOptionPane.WARNING_MESSAGE ); } System.exit(10); } - // end of java6 only code + // end of java 8 only code MainImpl.main(args); } - - + + private static boolean checkJavaVersion(int required) { + if (required < 11) { + throw new IllegalArgumentException(); + } + try { + Object runtimeVersion = Runtime.class.getMethod("version").invoke(null); + return ((int) runtimeVersion.getClass().getMethod("feature").invoke(runtimeVersion)) >= required; + } catch (ReflectiveOperationException ex) { + return false; + } + } + + private static String getMessage(String key) { + return ResourceBundle.getBundle("org.netbeans.Bundle").getString(key); + } + + private static String getMessage(String key, int arg) { + return getMessage(key).replace("{0}", String.valueOf(arg)); + } + /** * Call when the system is up and running, to complete handling of * delayed command-line options like -open FILE. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists