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

Fix commit validation jdk16+ #3862

Merged

Conversation

matthiasblaesing
Copy link
Contributor

The intention of this PR is to enable running commit-validation on JDK 18. The first commit just enables running NetBeans on JDK 18. The second commit contains the changes necessary to enable running tests on JDK 18:

  • Add missing library to batik dependency reported on JDK 11+
  • Add opens/exports used for NetBeans IDE also to unittest runs by default
  • Set system property java.security.manager to allow for unittest runs
  • Remove version filter from VerifySimpleTemplatesTest so that the string template tests are actually run
  • Remove test.run.args where covered by common definition
  • Add special test.run.args to ide.kit (adding module jdk.jdi and exporting com.sun.jdi) and java.hints (supressing the add-opens definitions from the default arguments)

@mbien
Copy link
Member

mbien commented Mar 25, 2022

  • Set system property java.security.manager to allow for unittest runs

@matthiasblaesing have you tested this on older JDKs? Since JDKs pre SM deprecation don't know what 'allow' means.

jdk-8.322.06.1-corretto/bin/java -Djava.security.manager=allow -version
Error occurred during initialization of VM
java.lang.InternalError: Could not create SecurityManager: allow
	at sun.misc.Launcher.<init>(Launcher.java:106)
	at sun.misc.Launcher.<clinit>(Launcher.java:54)
	at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1444)
	at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1429)
jdk-11.0.14.9.1-corretto/bin/java -Djava.security.manager=allow -version
Error occurred during initialization of VM
java.lang.Error: Could not create SecurityManager
	at java.lang.System.initPhase3(java.base@11.0.14/System.java:2065)
Caused by: java.lang.ClassNotFoundException: allow
	at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@11.0.14/BuiltinClassLoader.java:581)
	at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@11.0.14/ClassLoaders.java:178)
	at java.lang.ClassLoader.loadClass(java.base@11.0.14/ClassLoader.java:522)
	at java.lang.Class.forName0(java.base@11.0.14/Native Method)
	at java.lang.Class.forName(java.base@11.0.14/Class.java:398)
	at java.lang.System.initPhase3(java.base@11.0.14/System.java:2050)
jdk-17.0.2.8.1-corretto/bin/java -Djava.security.manager=allow -version
openjdk version "17.0.2" 2022-01-18 LTS
OpenJDK Runtime Environment Corretto-17.0.2.8.1 (build 17.0.2+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.2.8.1 (build 17.0.2+8-LTS, mixed mode, sharing)

(thats why i had to set it conditional on the gh actions pipeline PR)

@matthiasblaesing
Copy link
Contributor Author

@mbien yes and no. I tested on Linux, but it fails on mac OS. I'm currently testing to add security manager disabling dynamically based on the target JDK.

@matthiasblaesing
Copy link
Contributor Author

@jlahoda could you please have a look at this:

https://app.travis-ci.com/github/apache/netbeans/jobs/564742204#L11668-L11694

    [junit] Caused: java.lang.NullPointerException: Cannot read field "tsym" because "imp.qualid.selected.type" is null
    [junit] 	at com.sun.tools.javac.comp.Check.checkImportedPackagesObservable(Check.java:4031)
    [junit] 	at com.sun.tools.javac.comp.TypeEnter.finishImports(TypeEnter.java:229)
    [junit] 	at com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:214)
    [junit] 	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:682)
    [junit] 	at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1410)
    [junit] 	at com.sun.tools.javac.comp.Enter.complete(Enter.java:610)
    [junit] 	at com.sun.tools.javac.comp.Enter.main(Enter.java:587)
    [junit] 	at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1042)
    [junit] 	at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:345)
    [junit] 	at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:282)
    [junit] 	at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:747)
    [junit] 	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:540)
    [junit] 	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:141)
    [junit] 	at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:608)
    [junit] 	at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:239)
    [junit] 	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:775)
    [junit] 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279)
    [junit] 	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
    [junit] [catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
    [junit] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    [junit] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    [junit] 	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    [junit] 	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    [junit] 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
    [junit] 	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
    [junit] ALL [null]: An error occurred during parsing of '/home/travis/build/apache/netbeans/ide/ide.kit/build/test/qa-functional/work/o.n.m.i.k.V/at/Test41.java'. Please report a bug against java/source and attach dump file '/home/travis/build/apache/netbeans/ide/ide.kit/build/test/qa-functional/work/userdir0/var/log/Test41.dump'.

The marked lines is part of the output of the org.netbeans.modules.ide.kit.VerifySimpleTemplatesTest.VerifySimpleTemplatesTest (in ide/ide.kit). It seems, that the error comes out of the javac which is fed incomplete information.

Locally I can reproduce the problem sometimes. Using this branch on JDK 11 I get the error after a clean build (with JDK 11 on the PATH):

git clean -f -x -d
ant
ant commit-validation

Maybe you have an idea how we could stabilize this. This might be a real problem in the infrastructure, as the test was not run on 9+ before this PR (see the removed filter in ide/ide.kit/test/qa-functional/src/org/netbeans/modules/ide/kit/VerifySimpleTemplatesTest.java). If I read the test procedure correctly, the test fails because it is configured to fail if an exception is logged, which is the case.

@mbien
Copy link
Member

mbien commented Mar 30, 2022

@matthiasblaesing Hi Matthias, the new CI pipeline has two setup steps at the moment as temp workaround

- name: SM config
if: ${{ matrix.java == '19-ea' }}
run: echo "SECURITY_MANAGER_OPTIONS=-Djava.security.manager=allow" >> $GITHUB_ENV
- name: JMS config
if: ${{ matrix.java != '8' }}
run: echo "JAVA_TOOL_OPTIONS=$SECURITY_MANAGER_OPTIONS --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED" >> $GITHUB_ENV

If this PR is integrated the steps would be redundant (and could cause trouble) - feel free to rebase and remove those two steps, this would also automatically provide a test setup for your update since the new workflow tests on more JDKs as you know.

Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

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

excellent job

@matthiasblaesing
Copy link
Contributor Author

@mbien thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants