From 7e625c44a472d45a513ada1e6ef7526c6d3a7720 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Mon, 29 Jan 2024 19:59:36 +0100 Subject: [PATCH 1/2] bump JDK from 11 to 17 as new minimum requirement for NB 22 - add 22-ea to the matrix - exclude some matrix elements for master, this frees more for label-controlled PRs without worsening the whack-a-mole factor bump action versions to fix deprecation warnings: - actions/cache to v4 - actions/setup-java to v4 - actions/setup-node to v4 add retry script to - ide/libs.git - ide/notifications - commit-validation run some tests on JDK 11 which don't work on 17+ tests which require a js script engine: - many platform/(api.)templates tests require js - profiler/profiler.oql OQL does also require js, - BindingsNGTest in webcommon/api.knockout and - TemplatesMimeTypeTest in platform/openide.loaders too other reasons - platform/core.network fails on 17+ --- .github/workflows/dependency-checks.yml | 8 +- .github/workflows/main.yml | 179 +++++++++++------- .../native-binary-build-lib.profiler.yml | 2 +- README.md | 4 +- .../o.n.bootstrap/src/org/netbeans/Main.java | 2 +- .../nbproject/project.properties | 12 +- 6 files changed, 118 insertions(+), 89 deletions(-) diff --git a/.github/workflows/dependency-checks.yml b/.github/workflows/dependency-checks.yml index dcf5fdc41ac1..034aca8b53c7 100644 --- a/.github/workflows/dependency-checks.yml +++ b/.github/workflows/dependency-checks.yml @@ -39,12 +39,6 @@ jobs: timeout-minutes: 20 steps: - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: '22-ea' - distribution: 'zulu' - - name: Checkout ${{ github.ref }} ( ${{ github.sha }} ) uses: actions/checkout@v4 with: @@ -59,6 +53,6 @@ jobs: mvn -q dependency:copy -Dartifact=com.google.code.gson:gson:2.10.1 -DoutputDirectory=./lib mvn -q dependency:copy -Dartifact=org.apache.maven:maven-artifact:3.9.6 -DoutputDirectory=./lib echo "
" >> $GITHUB_STEP_SUMMARY
-          java --enable-preview --source 22 -cp "lib/*" .github/scripts/BinariesListUpdates.java ./ | tee -a $GITHUB_STEP_SUMMARY
+          $JAVA_HOME_21_X64/bin/java --enable-preview --source 21 -cp "lib/*" .github/scripts/BinariesListUpdates.java ./ | tee -a $GITHUB_STEP_SUMMARY
           echo "
" >> $GITHUB_STEP_SUMMARY rm -Rf lib diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 591491551d0f..30f49a083e67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -109,7 +109,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11', '21' ] + java: [ '17', '21', '22-ea' ] fail-fast: false steps: @@ -127,7 +127,7 @@ jobs: show-progress: false - name: Caching dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.hgexternalcache key: ${{ runner.os }}-${{ hashFiles('*/external/binaries-list', '*/*/external/binaries-list') }} @@ -137,11 +137,11 @@ jobs: run: ant $OPTS -quiet -Dcluster.config=$CLUSTER_CONFIG build-nozip - name: Prepare Artifact - if: ${{ matrix.java == '11' }} + if: ${{ matrix.java == '17' }} run: tar -I 'zstd -9 -T0' -cf /tmp/build.tar.zst --exclude ".git" . - name: Upload Workspace - if: ${{ (matrix.java == '11') && success() }} + if: ${{ (matrix.java == '17') && success() }} uses: actions/upload-artifact@v4 with: name: build @@ -151,11 +151,11 @@ jobs: if-no-files-found: error - name: Create Dev Build - if: ${{ matrix.java == '11' && contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && success() }} + if: ${{ matrix.java == '17' && contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && success() }} run: ant $OPTS -quiet -Dcluster.config=$CLUSTER_CONFIG zip-cluster-config - name: Upload Dev Build - if: ${{ matrix.java == '11' && contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && success() }} + if: ${{ matrix.java == '17' && contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && success() }} uses: actions/upload-artifact@v4 with: name: dev-build @@ -178,13 +178,13 @@ jobs: submodules: false show-progress: false - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: ${{ env.default_java_distribution }} - java-version: 11 + java-version: 17 - name: Caching dependencies - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: ~/.hgexternalcache key: ${{ runner.os }}-${{ hashFiles('*/external/binaries-list', '*/*/external/binaries-list') }} @@ -201,7 +201,7 @@ jobs: run: ant $OPTS commit-validation -Dnbjavac.class.path=java/libs.javacapi/external/*.jar # secondary jobs - linux-commit-validation: + commit-validation: name: CV on ${{ matrix.os }}/JDK ${{ matrix.java }} needs: base-build runs-on: ${{ matrix.os }} @@ -209,7 +209,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - java: [ 11 ] + java: [ 17 ] include: - os: ubuntu-latest java: 21 @@ -246,14 +246,21 @@ jobs: if: contains(matrix.os, 'macos') && success() run: ant $OPTS -f platform/masterfs.macosx test + - name: Commit Validation tests + run: .github/retry.sh ant $OPTS -Dcluster.config=$CLUSTER_CONFIG commit-validation + + - name: Set up JDK 11 for core.network + uses: actions/setup-java@v4 + if: matrix.java == 17 && success() + with: + java-version: 11 + distribution: ${{ env.default_java_distribution }} + # fails on 17+ - name: platform/core.network - if: matrix.java == 11 && success() + if: matrix.java == 17 && success() run: ant $OPTS -f platform/core.network test - - name: Commit Validation tests - run: ant $OPTS -Dcluster.config=$CLUSTER_CONFIG commit-validation - - name: Create Test Summary uses: test-summary/action@v2 if: failure() @@ -273,7 +280,7 @@ jobs: ANT_OPTS: -Dmetabuild.jsonurl=https://raw.githubusercontent.com/apache/netbeans-jenkins-lib/master/meta/netbeansrelease.json strategy: matrix: - java: [ '11' ] + java: [ '17' ] steps: - name: Set up JDK ${{ matrix.java }} @@ -338,7 +345,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -371,7 +379,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -405,8 +414,9 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] config: [ 'platform', 'release' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -424,7 +434,7 @@ jobs: run: tar --zstd -xf build.tar.zst - name: Restoring Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: ~/.hgexternalcache key: ${{ runner.os }}-${{ hashFiles('*/external/binaries-list', '*/*/external/binaries-list') }} @@ -446,7 +456,7 @@ jobs: # extra round for VSCodeExt which is built with 'release' config - name: Set up node if: ${{ (matrix.config == 'release') && success() }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 @@ -464,7 +474,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -661,7 +672,7 @@ jobs: run: ant $OPTS -f ide/libs.freemarker test - name: ide/libs.git - run: ant $OPTS -f ide/libs.git test + run: .github/retry.sh ant $OPTS -f ide/libs.git test - name: ide/libs.graalsdk run: ant $OPTS -f ide/libs.graalsdk test @@ -676,7 +687,7 @@ jobs: run: ant $OPTS -f ide/lsp.client test - name: ide/notifications - run: ant $OPTS -f ide/notifications test + run: .github/retry.sh ant $OPTS -f ide/notifications test - name: ide/o.openidex.util run: ant $OPTS -f ide/o.openidex.util test @@ -812,7 +823,7 @@ jobs: build-tools: - name: Build Tools on Linux/JDK ${{ matrix.java }} (some on 17) + name: Build-Tools on Linux/JDK ${{ matrix.java }} # label triggers: Ant, Gradle, Maven, MX if: ${{ contains(github.event.pull_request.labels.*.name, 'Ant') || contains(github.event.pull_request.labels.*.name, 'Gradle') || contains(github.event.pull_request.labels.*.name, 'Maven') || contains(github.event.pull_request.labels.*.name, 'MX') || contains(github.event.pull_request.labels.*.name, 'ci:all-tests') || github.event_name != 'pull_request' }} needs: base-build @@ -820,7 +831,9 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11', '17', '21' ] + java: [ '17', '21', '22-ea' ] + exclude: + - java: ${{ github.event_name == 'pull_request' && 'nothing' || '21' }} fail-fast: false steps: @@ -908,18 +921,23 @@ jobs: distribution: ${{ env.default_java_distribution }} - name: java/java.mx.project + if: ${{ matrix.java == '17' }} run: .github/retry.sh ant $OPTS -f java/java.mx.project test - name: java/gradle.java + if: ${{ matrix.java == '17' }} run: .github/retry.sh ant $OPTS -f java/gradle.java test - name: extide/gradle + if: ${{ matrix.java == '17' }} run: ant $OPTS -f extide/gradle test - name: java/gradle.dependencies + if: ${{ matrix.java == '17' }} run: ant $OPTS -f java/gradle.dependencies test - name: extide/o.apache.tools.ant.module + if: ${{ matrix.java == '17' }} run: ant $OPTS -f extide/o.apache.tools.ant.module test - name: Create Test Summary @@ -938,7 +956,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -984,9 +1003,6 @@ jobs: - name: platform/api.search run: ant $OPTS -f platform/api.search test - - name: platform/api.templates - run: ant $OPTS -f platform/api.templates test - - name: platform/api.visual run: ant $OPTS -f platform/api.visual test @@ -1119,15 +1135,10 @@ jobs: timeout-minutes: 90 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - java-version: 11 - distribution: ${{ env.default_java_distribution }} - - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v4 with: @@ -1231,9 +1242,6 @@ jobs: - name: platform/spi.quicksearch run: ant $OPTS -f platform/spi.quicksearch test - - name: platform/templates - run: ant $OPTS -f platform/templates test - - name: platform/templatesui run: ant $OPTS -f platform/templatesui test @@ -1243,6 +1251,22 @@ jobs: - name: platform/o.n.bootstrap run: ant $OPTS -f platform/o.n.bootstrap test + - name: Set up JDK 11 for platform/templates + uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: ${{ env.default_java_distribution }} + + # TODO tests rely on javax.script.ScriptEngine / js which locks this to JDK 11 + - name: platform/templates + run: ant $OPTS -f platform/templates test + + - name: platform/api.templates + run: ant $OPTS -f platform/api.templates test + + - name: platform/openide.loaders TemplatesMimeTypeTest + run: ant $OPTS -f platform/openide.loaders test -Dtest.config.default.includes=**/TemplatesMimeTypeTest.class -Dtest.config.default.excludes="" + - name: Create Test Summary uses: test-summary/action@v2 if: failure() @@ -1259,7 +1283,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1325,7 +1350,8 @@ jobs: timeout-minutes: 100 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1514,6 +1540,7 @@ jobs: strategy: matrix: java: [ '8' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1566,8 +1593,10 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17', '21' ] config: [ 'batch1', 'batch2' ] + exclude: + - java: ${{ github.event_name == 'pull_request' && 'nothing' || '21' }} fail-fast: false steps: @@ -1617,7 +1646,9 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11', '21' ] + java: [ '17', '21', '22-ea' ] + exclude: + - java: ${{ github.event_name == 'pull_request' && 'nothing' || '21' }} fail-fast: false steps: @@ -1676,6 +1707,7 @@ jobs: strategy: matrix: java: [ '11' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1700,6 +1732,7 @@ jobs: - name: profiler run: ant $OPTS -f profiler/profiler test-unit + # TODO OQL requires js script engine which locks this to JDK 11 - name: profiler.oql run: ant $OPTS -f profiler/profiler.oql test @@ -1717,7 +1750,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1739,9 +1773,6 @@ jobs: - name: Extract run: tar --zstd -xf build.tar.zst - - name: webcommon/api.knockout - run: ant $OPTS -f webcommon/api.knockout test - # - name: webcommon/cordova # run: ant $OPTS -f webcommon/cordova test @@ -1839,6 +1870,16 @@ jobs: - name: webcommon/web.inspect run: ant $OPTS -f webcommon/web.inspect test + - name: Set up JDK 11 for webcommon/api.knockout + uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: ${{ env.default_java_distribution }} + + # TODO: requires js script engine + - name: webcommon/api.knockout + run: ant $OPTS -f webcommon/api.knockout test + - name: Create Test Summary uses: test-summary/action@v2 if: failure() @@ -1853,7 +1894,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1898,6 +1940,7 @@ jobs: strategy: matrix: java: [ '8' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1953,7 +1996,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -1992,13 +2036,14 @@ jobs: enterprise-test: - name: Enterprise on Linux/JDK ${{ matrix.java }} (some on 8 and 17) + name: Enterprise on Linux/JDK ${{ matrix.java }} (some on 8) needs: base-build runs-on: ubuntu-latest timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -2020,6 +2065,9 @@ jobs: - name: Extract run: tar --zstd -xf build.tar.zst + - name: micronaut + run: .github/retry.sh ant $OPTS -f enterprise/micronaut test + - name: api.web.webmodule run: ant $OPTS -f enterprise/api.web.webmodule test @@ -2230,15 +2278,6 @@ jobs: - name: j2ee.dd.webservice run: ant $OPTS -f enterprise/j2ee.dd.webservice test - - name: Set up JDK 17 for tests that are not compatible with JDK 11 - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: ${{ env.default_java_distribution }} - - - name: micronaut - run: .github/retry.sh ant $OPTS -f enterprise/micronaut test - - name: Create Test Summary uses: test-summary/action@v2 if: failure() @@ -2253,7 +2292,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -2318,7 +2358,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false services: mysql: @@ -2377,7 +2418,7 @@ jobs: DISPLAY: ":99.0" strategy: matrix: - java: [ '11' ] + java: [ '17' ] os: [ 'windows-latest', 'ubuntu-latest' ] fail-fast: false steps: @@ -2519,7 +2560,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -2624,7 +2666,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - java: [ '11' ] + java: [ '17' ] + fail-fast: false steps: - name: Set up JDK ${{ matrix.java }} @@ -2634,7 +2677,7 @@ jobs: distribution: ${{ env.default_java_distribution }} - name: Set up node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 @@ -2667,7 +2710,7 @@ jobs: name: Cleanup Workflow Artifacts needs: - base-build - - linux-commit-validation + - commit-validation - paperwork - build-system-test - build-nbms diff --git a/.github/workflows/native-binary-build-lib.profiler.yml b/.github/workflows/native-binary-build-lib.profiler.yml index 3b7ba9223233..e17a41ace275 100644 --- a/.github/workflows/native-binary-build-lib.profiler.yml +++ b/.github/workflows/native-binary-build-lib.profiler.yml @@ -93,7 +93,7 @@ jobs: show-progress: false - name: Caching dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.hgexternalcache key: profiler-${{ runner.os }}-${{ hashFiles('*/external/binaries-list', '*/*/external/binaries-list') }} diff --git a/README.md b/README.md index 6c4ac6d2a18c..ec0e20700a53 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Apache NetBeans is an open source development environment, tooling platform, and ### Requirements * Git - * Ant 1.9.9 or above - * JDK 11 or above (to build and run NetBeans) + * Ant + * JDK 17 or above (to build and run NetBeans) #### Notes: diff --git a/platform/o.n.bootstrap/src/org/netbeans/Main.java b/platform/o.n.bootstrap/src/org/netbeans/Main.java index e15d779d1a7e..15337fc08193 100644 --- a/platform/o.n.bootstrap/src/org/netbeans/Main.java +++ b/platform/o.n.bootstrap/src/org/netbeans/Main.java @@ -37,7 +37,7 @@ private Main() { public static void main (String args[]) throws Exception { // following code has to execute on java 8 - e.g. do not use // NbBundle or any other library - int required = 11; + int required = 17; if (Boolean.getBoolean("bootstrap.disableJDKCheck")) { System.err.println(getMessage("MSG_WarnJavaCheckDisabled")); diff --git a/platform/openide.loaders/nbproject/project.properties b/platform/openide.loaders/nbproject/project.properties index efa4e853b18a..76c4ce2c5edf 100644 --- a/platform/openide.loaders/nbproject/project.properties +++ b/platform/openide.loaders/nbproject/project.properties @@ -22,13 +22,5 @@ javadoc.main.page=org/openide/loaders/doc-files/api.html javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml -test.config.stableBTD.includes=**/*Test.class -test.config.stableBTD.excludes=\ - **/AWTTaskTest.class,\ - **/DataNodeTest.class,\ - **/DefaultDataObjectMissingBinaryTest.class,\ - **/FolderChildrenTest.class,\ - **/LoggingControlTest.class,\ - **/MenuBarTest.class,\ - **/SCFTHandlerTest.class,\ - **/ToolbarConfigurationDeadlockTest.class +# requires js script engine +test.config.default.excludes=**/TemplatesMimeTypeTest.class From a0109cc64b268a9af6a1713547647732d8637a78 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Tue, 30 Jan 2024 22:58:05 +0100 Subject: [PATCH 2/2] Fix various tests so that they can run on JDK 17 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix CanProxyToLocalhostTest: Proxy#toString changed slightly fix JavaCompletionTask121FeaturesTest: add Record to test data fix ConvertToRecordPatternTest and ConvertToNestedRecordPatternTest - enforce parsable source level for hint tests - update record patern syntax in tests fix BroadCatchBlockTest: use stable/jdk-independent test files - jdk keeps removing throws declarations from methods, esp when they extend RuntimeException -> lets make our own test Klasses Stabilize JS Test testIssue215777 by Matthias - split golden files into two NbTestCase method ordering is always using "natural" order - ClassLoader fields can not be accessed via reflection on JDK 12+ - test method ordering options are not used anywhere atm - disable tests Co-authored-by: Matthias Bläsing --- .../src/org/netbeans/junit/MethodOrder.java | 4 + .../src/org/netbeans/junit/OrderAZTest.java | 3 + .../src/org/netbeans/junit/OrderTest.java | 5 +- .../src/org/netbeans/junit/OrderZATest.java | 3 + ...letion_CaseBody_PatternMatchingSwitch.pass | 1 + ...pletion_Guard_PatternMatchingSwitch_1.pass | 1 + .../modules/java/hints/test/api/HintTest.java | 152 +++++++++--------- .../BroadCatchBlockTest/TwoExceptions.java | 13 +- .../TwoExceptionsMulti.java | 13 +- .../BroadCatchBlockTest/TwoExceptions.java | 13 +- .../modules/java/hints/ImportsTest.java | 2 +- .../java/hints/bugs/BroadCatchBlockTest.java | 11 +- .../jdk/ConvertSwitchToRuleSwitchTest.java | 62 +++---- .../jdk/ConvertTextBlockToStringTest.java | 24 +-- .../jdk/ConvertToNestedRecordPatternTest.java | 42 ++--- .../hints/jdk/ConvertToRecordPatternTest.java | 31 ++-- .../hints/jdk/ConvertToTextBlockTest.java | 8 +- .../core/CanProxyToLocalhostTest.java | 5 +- .../{issue215777.js => issue215777_01.js} | 1 - ...15777_01.js.testIssue215777_01.completion} | 0 .../testfiles/completion/issue215777_02.js | 1 + ...15777_02.js.testIssue215777_02.completion} | 1 - .../editor/JsCodeCompletionGeneralTest.java | 4 +- 23 files changed, 209 insertions(+), 191 deletions(-) rename webcommon/javascript2.editor/test/unit/data/testfiles/completion/{issue215777.js => issue215777_01.js} (52%) rename webcommon/javascript2.editor/test/unit/data/testfiles/completion/{issue215777.js.testIssue215777_01.completion => issue215777_01.js.testIssue215777_01.completion} (100%) create mode 100644 webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_02.js rename webcommon/javascript2.editor/test/unit/data/testfiles/completion/{issue215777.js.testIssue215777_02.completion => issue215777_02.js.testIssue215777_02.completion} (98%) diff --git a/harness/nbjunit/src/org/netbeans/junit/MethodOrder.java b/harness/nbjunit/src/org/netbeans/junit/MethodOrder.java index ae0c9bd6914b..858e1b4b19aa 100644 --- a/harness/nbjunit/src/org/netbeans/junit/MethodOrder.java +++ b/harness/nbjunit/src/org/netbeans/junit/MethodOrder.java @@ -43,6 +43,9 @@ static void initialize() { String orderS = findOrder(); if (!"natural".equals(orderS)) { // NOI18N try { + // TODO: ClassLoader fields can not be accessed via reflection on JDK 12+ + // see jdk.internal.reflect.Reflection#fieldFilterMap + // this won't work Field classesF = ClassLoader.class.getDeclaredField("classes"); // NOI18N classesF.setAccessible(true); @SuppressWarnings("unchecked") @@ -53,6 +56,7 @@ static void initialize() { } } } catch (Exception x) { + System.err.println("WARNING: test method ordering disabled"); x.printStackTrace(); } } diff --git a/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderAZTest.java b/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderAZTest.java index 569a8b19c12a..cf2ce07dd182 100644 --- a/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderAZTest.java +++ b/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderAZTest.java @@ -22,6 +22,7 @@ import junit.framework.TestResult; import junit.framework.TestSuite; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; /** Check the a-z behaviour. @@ -33,6 +34,8 @@ public class OrderAZTest { System.setProperty("NbTestCase.order", "a-z"); } + // method order isn't working, see comment in org.netbeans.junit.MethodOrder + @Ignore @Test public void shuffleTest() throws ClassNotFoundException { Class load = Class.forName("org.netbeans.junit.OrderHid"); TestSuite ts = new TestSuite(load); diff --git a/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderTest.java b/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderTest.java index 97d5f0b1dfe8..43d4ee7f704d 100644 --- a/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderTest.java +++ b/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderTest.java @@ -22,6 +22,7 @@ import junit.framework.TestResult; import junit.framework.TestSuite; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; /** Check the shuffle behaviour. @@ -32,7 +33,9 @@ public class OrderTest { static { System.setProperty("NbTestCase.order", "1314372086210"); } - + + // method order isn't working, see comment in org.netbeans.junit.MethodOrder + @Ignore @Test public void shuffleTest() throws ClassNotFoundException { Class load = Class.forName("org.netbeans.junit.OrderHid"); TestSuite ts = new TestSuite(load); diff --git a/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderZATest.java b/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderZATest.java index a11bde5204e6..ec88e288ad85 100644 --- a/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderZATest.java +++ b/harness/nbjunit/test/unit/src/org/netbeans/junit/OrderZATest.java @@ -22,6 +22,7 @@ import junit.framework.TestResult; import junit.framework.TestSuite; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; /** Check the z-a behaviour. @@ -33,6 +34,8 @@ public class OrderZATest { System.setProperty("NbTestCase.order", "z-a"); } + // method order isn't working, see comment in org.netbeans.junit.MethodOrder + @Ignore @Test public void shuffleTest() throws ClassNotFoundException { Class load = Class.forName("org.netbeans.junit.OrderHid"); TestSuite ts = new TestSuite(load); diff --git a/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_CaseBody_PatternMatchingSwitch.pass b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_CaseBody_PatternMatchingSwitch.pass index 615e4fb668e5..ab6c90ee2a5a 100644 --- a/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_CaseBody_PatternMatchingSwitch.pass +++ b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_CaseBody_PatternMatchingSwitch.pass @@ -115,6 +115,7 @@ Process ProcessBuilder ProcessHandle Readable +Record ReflectiveOperationException Runnable Runtime diff --git a/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_Guard_PatternMatchingSwitch_1.pass b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_Guard_PatternMatchingSwitch_1.pass index 572d58bebaf1..315c11c6d36d 100644 --- a/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_Guard_PatternMatchingSwitch_1.pass +++ b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/AutoCompletion_Guard_PatternMatchingSwitch_1.pass @@ -96,6 +96,7 @@ Process ProcessBuilder ProcessHandle Readable +Record ReflectiveOperationException Runnable Runtime diff --git a/java/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java b/java/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java index 02beebcf0753..7efea72a98fc 100644 --- a/java/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java +++ b/java/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java @@ -80,13 +80,11 @@ import org.netbeans.modules.java.hints.providers.code.FSWrapper; import org.netbeans.modules.java.hints.providers.code.FSWrapper.ClassWrapper; import org.netbeans.modules.java.hints.providers.spi.HintDescription; -import org.netbeans.modules.java.hints.providers.spi.HintDescription.Worker; import org.netbeans.modules.java.hints.providers.spi.HintDescriptionFactory; import org.netbeans.modules.java.hints.providers.spi.HintMetadata; import org.netbeans.modules.java.hints.providers.spi.HintMetadata.Options; import org.netbeans.modules.java.hints.spiimpl.JavaFixImpl; import org.netbeans.modules.java.hints.spiimpl.JavaFixImpl.Accessor; -import org.netbeans.modules.java.hints.spiimpl.MessageImpl; import org.netbeans.modules.java.hints.spiimpl.SyntheticFix; import org.netbeans.modules.java.hints.spiimpl.batch.BatchUtilities; import org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker; @@ -98,7 +96,6 @@ import org.netbeans.modules.parsing.api.indexing.IndexingManager; import org.netbeans.modules.parsing.impl.indexing.CacheFolder; import org.netbeans.modules.parsing.impl.indexing.MimeTypes; -import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation; import org.netbeans.spi.editor.hints.ErrorDescription; import org.netbeans.spi.editor.hints.Fix; import org.netbeans.spi.editor.hints.Severity; @@ -177,7 +174,7 @@ public class HintTest { private final FileObject cache; private final Preferences testPreferences; private final HintsSettings hintSettings; - private final List checkCompilable = new ArrayList(); + private final List checkCompilable = new ArrayList<>(); private String sourceLevel = "1.5"; private List extraOptions = new ArrayList<>(); private Character caretMarker; @@ -187,7 +184,7 @@ public class HintTest { private ClassPath compileClassPath = ClassPathSupport.createClassPath(new URL[0]); private HintTest() throws Exception { - List layers = new LinkedList(); + List layers = new LinkedList<>(); for (String layer : new String[] {"META-INF/generated-layer.xml"}) { boolean found = false; @@ -222,9 +219,9 @@ private HintTest() throws Exception { Set amt = MimeTypes.getAllMimeTypes(); if (amt == null) { - amt = new HashSet(); + amt = new HashSet<>(); } else { - amt = new HashSet(amt); + amt = new HashSet<>(amt); } amt.add("text/x-java"); MimeTypes.setAllMimeTypes(amt); @@ -381,12 +378,27 @@ private void ensureCompilable(FileObject file) throws IOException, AssertionErro } } + /**Sets a source level for all Java files used in this test. + * + * @param sourceLevel the source level to use while parsing Java files + * @return itself + */ + public HintTest sourceLevel(int sourceLevel) { + assertTrue(sourceLevel >= 8); + return this.sourceLevel(Integer.toString(sourceLevel)); + } + /**Sets a source level for all Java files used in this test. * * @param sourceLevel the source level to use while parsing Java files * @return itself */ public HintTest sourceLevel(String sourceLevel) { + try { + int valid = sourceLevel.startsWith("1.") ? Integer.parseInt(sourceLevel.substring(2)) : Integer.parseInt(sourceLevel); + } catch (NumberFormatException ex) { + throw new IllegalArgumentException(ex); + } this.sourceLevel = sourceLevel; return this; } @@ -459,8 +471,8 @@ public HintOutput run(Class hint, String hintCode) throws Exception { ensureCompilable(file); } - Map> hints = new HashMap>(); - List found = new ArrayList(); + Map> hints = new HashMap<>(); + List found = new ArrayList<>(); for (ClassWrapper w : FSWrapper.listClasses()) { if (hint.getCanonicalName().equals(w.getName().replace('$', '.'))) { @@ -474,8 +486,8 @@ public HintOutput run(Class hint, String hintCode) throws Exception { CodeHintProviderImpl.processClass(w, hints); } - List total = new LinkedList(); - final Set requiresJavaFix = Collections.newSetFromMap(new IdentityHashMap()); + List total = new LinkedList<>(); + final Set requiresJavaFix = Collections.newSetFromMap(new IdentityHashMap<>()); for (final Entry> e : hints.entrySet()) { if (null != hintCode && !e.getKey().id.equals(hintCode)) { @@ -493,20 +505,16 @@ public HintOutput run(Class hint, String hintCode) throws Exception { .setMetadata(e.getKey()) .setAdditionalConstraints(hd.getAdditionalConstraints()) .addOptions(hd.getOptions().toArray(new Options[0])) - .setWorker(new Worker() { - @Override public Collection createErrors(HintContext ctx) { - Collection errors = hd.getWorker().createErrors(ctx); - - if (errors != null) { - for (ErrorDescription ed : errors) { - requiresJavaFix.add(ed); - } - } - - return errors; - } - }) - .produce()); + .setWorker((HintContext ctx) -> { + Collection errors = hd.getWorker().createErrors(ctx); + if (errors != null) { + for (ErrorDescription ed : errors) { + requiresJavaFix.add(ed); + } + } + return errors; + }) + .produce()); } } @@ -514,7 +522,7 @@ public HintOutput run(Class hint, String hintCode) throws Exception { assertNotNull(info); - List result = new ArrayList(); + List result = new ArrayList<>(); Handler h = new Handler() { @Override public void publish(LogRecord record) { @@ -534,10 +542,10 @@ public HintOutput run(Class hint, String hintCode) throws Exception { result.addAll(e.getValue()); } - Collections.sort(result, ERRORS_COMPARATOR); + result.sort(ERRORS_COMPARATOR); - Reference infoRef = new WeakReference(info); - Reference cut = new WeakReference(info.getCompilationUnit()); + Reference infoRef = new WeakReference<>(info); + Reference cut = new WeakReference<>(info.getCompilationUnit()); info = null; @@ -551,7 +559,7 @@ public HintOutput run(Class hint, String hintCode) throws Exception { //must keep the error descriptions (and their Fixes through them) in a field //so that assertGC is able to provide a useful trace of references: - private static Set> DEBUGGING_HELPER = Collections.newSetFromMap(new IdentityHashMap, Boolean>()); + private static Set> DEBUGGING_HELPER = Collections.newSetFromMap(new IdentityHashMap<>()); private CompilationInfo parse(FileObject file) throws DataObjectNotFoundException, IllegalArgumentException, IOException { DataObject od = DataObject.find(file); @@ -576,7 +584,7 @@ private CompilationInfo parse(FileObject file) throws DataObjectNotFoundExceptio } private Map> computeErrors(CompilationInfo info, Iterable hints, AtomicBoolean cancel) { - return new HintsInvoker(hintSettings, caret, cancel).computeHints(info, new TreePath(info.getCompilationUnit()), hints, new LinkedList()); + return new HintsInvoker(hintSettings, caret, cancel).computeHints(info, new TreePath(info.getCompilationUnit()), hints, new LinkedList<>()); } FileObject getSourceRoot() { @@ -596,28 +604,36 @@ private TempPreferences(TempPreferences parent, String name) { newNode = true; } + @Override protected final String getSpi(String key) { return properties().getProperty(key); } + @Override protected final String[] childrenNamesSpi() throws BackingStoreException { return new String[0]; } + @Override protected final String[] keysSpi() throws BackingStoreException { return properties().keySet().toArray(new String[0]); } + @Override protected final void putSpi(String key, String value) { properties().put(key,value); } + @Override protected final void removeSpi(String key) { properties().remove(key); } + @Override protected final void removeNodeSpi() throws BackingStoreException {} + @Override protected void flushSpi() throws BackingStoreException {} + @Override protected void syncSpi() throws BackingStoreException { properties().clear(); } @@ -643,6 +659,7 @@ Properties properties() { return properties; } + @Override protected AbstractPreferences childSpi(String name) { return new TempPreferences(this, name); } @@ -659,22 +676,21 @@ protected AbstractPreferences childSpi(String name) { private class TestSourceForBinaryQuery implements SourceForBinaryQueryImplementation { + @Override public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) { FileObject f = URLMapper.findFileObject(binaryRoot); if (buildRoot.equals(f)) { return new SourceForBinaryQuery.Result() { + @Override public FileObject[] getRoots() { return new FileObject[] { sourceRoot, }; } - public void addChangeListener(ChangeListener l) { - } - - public void removeChangeListener(ChangeListener l) { - } + @Override public void addChangeListener(ChangeListener l) {} + @Override public void removeChangeListener(ChangeListener l) {} }; } @@ -687,6 +703,7 @@ public void removeChangeListener(ChangeListener l) { private class TestProxyClassPathProvider implements ClassPathProvider { + @Override public ClassPath findClassPath(FileObject file, String type) { try { if (ClassPath.BOOT == type) { @@ -776,6 +793,7 @@ public DeadlockTask(Phase phase) { this.phase = phase; } + @Override public void run( CompilationController info ) { try { info.toPhase(this.phase); @@ -826,8 +844,8 @@ public HintOutput assertWarnings(String... warnings) { * @throws AssertionError if the given warnings do not match the actual warnings */ public HintOutput assertContainsWarnings(String... warnings) { - Set goldenSet = new HashSet(Arrays.asList(warnings)); - List errorsNames = new LinkedList(); + Set goldenSet = new HashSet<>(Arrays.asList(warnings)); + List errorsNames = new LinkedList<>(); for (ErrorDescription d : errors) { goldenSet.remove(d.toString()); @@ -849,8 +867,8 @@ public HintOutput assertContainsWarnings(String... warnings) { * @throws AssertionError if the given warnings contain the actual warnings */ public HintOutput assertNotContainsWarnings(String... warnings) { - Set goldenSet = new HashSet(Arrays.asList(warnings)); - List errorsNames = new LinkedList(); + Set goldenSet = new HashSet<>(Arrays.asList(warnings)); + List errorsNames = new LinkedList<>(); for (String warning : goldenSet) { if (warning.split(":").length >= 5) { @@ -942,7 +960,7 @@ public AppliedFix applyFix(String fix) throws Exception { assertTrue("Must be computed", warning.getFixes().isComputed()); List fixes = warning.getFixes().getFixes(); - List fixNames = new LinkedList(); + List fixNames = new LinkedList<>(); Fix toApply = null; for (Fix f : fixes) { @@ -989,19 +1007,15 @@ private void doApplyFix(Fix f) throws Exception { private ModificationResult runJavaFix(final JavaFix jf) throws IOException { FileObject file = Accessor.INSTANCE.getFile(jf); JavaSource js = JavaSource.forFileObject(file); - final Map> changes = new HashMap>(); - - ModificationResult mr = js.runModificationTask(new Task() { - public void run(WorkingCopy wc) throws Exception { - if (wc.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) { - return; - } + final Map> changes = new HashMap<>(); - Map resourceContentChanges = new HashMap(); - Accessor.INSTANCE.process(jf, wc, true, resourceContentChanges, /*Ignored for now:*/new ArrayList()); - BatchUtilities.addResourceContentChanges(resourceContentChanges, changes); - + ModificationResult mr = js.runModificationTask((WorkingCopy wc) -> { + if (wc.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) { + return; } + Map resourceContentChanges = new HashMap<>(); + Accessor.INSTANCE.process(jf, wc, true, resourceContentChanges, /*Ignored for now:*/new ArrayList<>()); + BatchUtilities.addResourceContentChanges(resourceContentChanges, changes); }); changes.putAll(JavaSourceAccessor.getINSTANCE().getDiffsFromModificationResult(mr)); @@ -1018,7 +1032,7 @@ public void run(WorkingCopy wc) throws Exception { public HintWarning assertFixes(String... expectedFixes) throws Exception { assertTrue("Must be computed", warning.getFixes().isComputed()); - List fixNames = new LinkedList(); + List fixNames = new LinkedList<>(); for (Fix f : warning.getFixes().getFixes()) { if (f instanceof SyntheticFix) continue; @@ -1040,7 +1054,7 @@ public HintWarning assertFixes(String... expectedFixes) throws Exception { public HintWarning assertFixesNotPresent(String... bannedFixes) throws Exception { assertTrue("Must be computed", warning.getFixes().isComputed()); - List fixNames = new LinkedList(); + List fixNames = new LinkedList<>(); for (Fix f : warning.getFixes().getFixes()) { if (f instanceof SyntheticFix) continue; fixNames.add(f.getText()); @@ -1269,11 +1283,8 @@ public String getOutput(String fileName) throws Exception { } } - private static final Comparator ERRORS_COMPARATOR = new Comparator () { - - public int compare (ErrorDescription e1, ErrorDescription e2) { - return e1.getRange ().getBegin ().getOffset () - e2.getRange ().getBegin ().getOffset (); - } + private static final Comparator ERRORS_COMPARATOR = (ErrorDescription e1, ErrorDescription e2) -> { + return e1.getRange().getBegin().getOffset() - e2.getRange().getBegin().getOffset(); }; static { @@ -1369,7 +1380,7 @@ private static String getWorkDirPath() { return realP; } - private static Set usedPaths = new HashSet(); + private static Set usedPaths = new HashSet<>(); private static String abbrevDots(String dotted) { StringBuilder sb = new StringBuilder(); @@ -1417,17 +1428,11 @@ private static String getWorkDirPathFromManager() { private static Properties readProperties() { Properties result = new Properties(); - try { - File propFile = getPreferencesFile(); - FileInputStream is = new FileInputStream(propFile); - try { - result.load(is); - } finally { - is.close(); - } + File propFile = getPreferencesFile(); + try (FileInputStream is = new FileInputStream(propFile)) { + result.load(is); } catch (IOException e) { } - return result; } @@ -1474,11 +1479,10 @@ private static void deleteSubFiles(File file) throws IOException { } } - private static FileObject copyStringToFile (FileObject f, String content) throws Exception { - OutputStream os = f.getOutputStream(); - os.write(content.getBytes(StandardCharsets.UTF_8)); - os.close (); - + private static FileObject copyStringToFile(FileObject f, String content) throws Exception { + try (OutputStream os = f.getOutputStream()) { + os.write(content.getBytes(StandardCharsets.UTF_8)); + } return f; } diff --git a/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java b/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java index bea79d9bae62..807c1c860aef 100644 --- a/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java +++ b/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java @@ -2,15 +2,20 @@ import java.io.FileInputStream; import java.io.IOException; -import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; import java.net.URL; -import java.util.Collections; public class TwoExceptions { + private static class StableMethod { + public Object invoke(Object obj, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {return null;} + } + private static class StableClass { + public StableMethod getDeclaredMethod(String name, Class... types) throws NoSuchMethodException, SecurityException {return null;} + } public void t() { - Class c = Collections.class; + StableClass c = new StableClass(); try { - Method m = c.getDeclaredMethod("foobar"); + StableMethod m = c.getDeclaredMethod("foobar"); m.invoke(null); } /* cmt */ catch (IllegalArgumentException ex) { /* cmt */ diff --git a/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptionsMulti.java b/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptionsMulti.java index 5ae98338b18b..e5e648150539 100644 --- a/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptionsMulti.java +++ b/java/java.hints/test/unit/data/goldenfiles/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptionsMulti.java @@ -2,15 +2,20 @@ import java.io.FileInputStream; import java.io.IOException; -import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; import java.net.URL; -import java.util.Collections; public class TwoExceptions { + private static class StableMethod { + public Object invoke(Object obj, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {return null;} + } + private static class StableClass { + public StableMethod getDeclaredMethod(String name, Class... types) throws NoSuchMethodException, SecurityException {return null;} + } public void t() { - Class c = Collections.class; + StableClass c = new StableClass(); try { - Method m = c.getDeclaredMethod("foobar"); + StableMethod m = c.getDeclaredMethod("foobar"); m.invoke(null); } /* cmt */ catch (IllegalArgumentException | SecurityException ex) { /* cmt */ diff --git a/java/java.hints/test/unit/data/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java b/java/java.hints/test/unit/data/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java index 76199789c9d5..2314244f1aca 100644 --- a/java/java.hints/test/unit/data/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java +++ b/java/java.hints/test/unit/data/org/netbeans/test/java/hints/BroadCatchBlockTest/TwoExceptions.java @@ -2,15 +2,20 @@ import java.io.FileInputStream; import java.io.IOException; -import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; import java.net.URL; -import java.util.Collections; public class TwoExceptions { + private static class StableMethod { + public Object invoke(Object obj, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {return null;} + } + private static class StableClass { + public StableMethod getDeclaredMethod(String name, Class... types) throws NoSuchMethodException, SecurityException {return null;} + } public void t() { - Class c = Collections.class; + StableClass c = new StableClass(); try { - Method m = c.getDeclaredMethod("foobar"); + StableMethod m = c.getDeclaredMethod("foobar"); m.invoke(null); } /* cmt */ catch (RuntimeException ex) { /* cmt */ diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/ImportsTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/ImportsTest.java index 3957dc7f5b83..1cd70f8478eb 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/ImportsTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/ImportsTest.java @@ -63,7 +63,7 @@ public void testUnusedSimpleRemove() throws Exception { public void testRedundantLangImportRemove() throws Exception { assumeTrue(Runtime.version().feature() >= 21); // API dependency HintTest.create() - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .options("--enable-preview") .input( "package test;\n" + diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/BroadCatchBlockTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/BroadCatchBlockTest.java index 75cce605e1fc..077eac9ce099 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/BroadCatchBlockTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/BroadCatchBlockTest.java @@ -79,10 +79,9 @@ public void testSingleParentException() throws Exception { /** * Checks that generic exception is reported even though * it corresponds to > 1 subclass. It also checks that common - * parents are not reported for neigher 'umbrellas' or normal exceptions. - * + * parents are not reported for neither 'umbrellas' or normal exceptions. */ - private static final String twoSubexceptionsGeneric = "14:27-14:46:verifier:The catch(java.lang.RuntimeException) is too broad, it catches the following exception types: java.lang.IllegalArgumentException and java.lang.SecurityException"; + private static final String twoSubexceptionsGeneric = "19:27-19:46:verifier:The catch(java.lang.RuntimeException) is too broad, it catches the following exception types: java.lang.IllegalArgumentException and java.lang.SecurityException"; public void testTwoSubexceptionsGeneric() throws Exception { final String warnTxt = twoSubexceptionsGeneric; createHintTest("TwoExceptions"). @@ -94,10 +93,10 @@ public void testTwoSubexceptionsGeneric() throws Exception { assertOutput(f(), g()); } - public void testTwoSubexceptionsGeneric7() throws Exception { + public void testTwoSubexceptionsGeneric2() throws Exception { final String warnTxt = twoSubexceptionsGeneric; createHintTest("TwoExceptions"). - sourceLevel("1.7"). + sourceLevel(8). run(BroadCatchBlock.class). assertWarnings(warnTxt). findWarning(warnTxt). @@ -149,7 +148,7 @@ public void testTwoCommonParentFixSeparateCatches() throws Exception { public void testTwoCommonParentFixMultiCatch() throws Exception { createHintTest("TwoExceptionsCommon"). preference(BroadCatchBlock.OPTION_EXCLUDE_COMMON, false). - sourceLevel("1.7"). + sourceLevel(8). run(BroadCatchBlock.class). assertWarnings(warn_twoCommonParents). findWarning(warn_twoCommonParents[0]). diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertSwitchToRuleSwitchTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertSwitchToRuleSwitchTest.java index 3323573ea75f..3e763142cc7d 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertSwitchToRuleSwitchTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertSwitchToRuleSwitchTest.java @@ -60,7 +60,7 @@ public void testSwitch2RuleSwitch() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -91,7 +91,7 @@ public void testLastNotBreak() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -122,7 +122,7 @@ public void testMultipleCases() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -153,7 +153,7 @@ public void testFallThrough() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .assertWarnings(); } @@ -173,7 +173,7 @@ public void testMissingLastBreak() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -204,7 +204,7 @@ public void testDefault() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -244,7 +244,7 @@ public void testVariables1() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -284,7 +284,7 @@ public void testFallThroughDefault1() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .assertWarnings(); } @@ -304,7 +304,7 @@ public void testFallThroughDefault2() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .assertWarnings(); } @@ -326,7 +326,7 @@ public void testTrailingEmptyCase() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -362,7 +362,7 @@ public void testNeedsPreview() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .assertWarnings(); } @@ -381,7 +381,7 @@ public void testBreakInside1() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .assertWarnings(); } @@ -402,7 +402,7 @@ public void testBreakInside2() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("4:9-4:15:verifier:Convert switch to rule switch") .applyFix() @@ -437,7 +437,7 @@ public void testContinueInside1() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .assertWarnings(); } @@ -460,7 +460,7 @@ public void testContinueInside2() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("5:13-5:19:verifier:Convert switch to rule switch") .applyFix() @@ -501,7 +501,7 @@ public void testSwitch2SwitchExpression() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -536,7 +536,7 @@ public void testSwitch2SwitchExpressionMultiCase() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:8-3:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -570,7 +570,7 @@ public void testSwitch2SwitchExpressionMultiCase2() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:8-3:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -601,7 +601,7 @@ public void testSwitch2SwitchExpressionOnlyDefault() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:8-3:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -636,7 +636,7 @@ public void testSwitch2SwitchExpressionNestedInnerSwitchExpression() throws Exce " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("4:9-4:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -671,7 +671,7 @@ public void testSwitch2SwitchExpressionReturnValue() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("2:9-2:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -701,7 +701,7 @@ public void testSwitch2SwitchExpressionTypeCast() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -731,7 +731,7 @@ public void testSwitch2SwitchExpressionTypeCastReturn() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("2:9-2:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -764,7 +764,7 @@ public void testSwitch2SwitchExpressionNestedSwitchExpression() throws Exception " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -806,7 +806,7 @@ public void testSwitch2SwitchExpressionNestedOuterSwitchStatement() throws Excep " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("4:9-4:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -851,7 +851,7 @@ public void testSwitch2SwitchExpressionNestedInnerSwitchStatement() throws Excep " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("6:16-6:22:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() @@ -893,7 +893,7 @@ public void testSwitchToRuleSwitchFormattingMultiple() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -924,7 +924,7 @@ public void testSwitchToRuleSwitchFormattingSimple() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -959,7 +959,7 @@ public void testSwitchToRuleSwitchBindingPattern() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel("21") + .sourceLevel(21) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -994,7 +994,7 @@ public void testSwitchToRuleSwitchGuardedPattern() throws Exception { " }\n" + " }\n" + "}\n") - .sourceLevel("21") + .sourceLevel(21) .run(ConvertSwitchToRuleSwitch.class) .findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch()) .applyFix() @@ -1030,7 +1030,7 @@ public void testSwitchExpressionGuardedPattern() throws Exception { + " }\n" + " }\n" + "}") - .sourceLevel("21") + .sourceLevel(21) .run(ConvertSwitchToRuleSwitch.class) .findWarning("2:8-2:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression()) .applyFix() diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertTextBlockToStringTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertTextBlockToStringTest.java index 8d37b5c6c39f..83667f51d00e 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertTextBlockToStringTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertTextBlockToStringTest.java @@ -46,7 +46,7 @@ public void newLineAtEnd() throws Exception { + " \"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -69,7 +69,7 @@ public void simpleTest() throws Exception { + " abc\"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -98,7 +98,7 @@ public void multipleNewLine() throws Exception { + " \"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -126,7 +126,7 @@ public void newLineAfter() throws Exception { + " ;\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -160,7 +160,7 @@ public void manyLineTextBlock() throws Exception { + " wxyz\"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -184,7 +184,7 @@ public void twoLineTextBlock() throws Exception { + " def\"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -209,7 +209,7 @@ public void twoNewLines() throws Exception { + " \"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -232,7 +232,7 @@ public void slashConvert() throws Exception { + " \\\\\"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -256,7 +256,7 @@ public void escapeCharTextBlock() throws Exception { + " \"def\"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -284,7 +284,7 @@ public void escapeCharTextBlock2() throws Exception { + " \"\"\";\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -308,7 +308,7 @@ public void textBlockAsParameter1() throws Exception { + " abc\"\"\");\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("4:27-4:30:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() @@ -333,7 +333,7 @@ public void textBlockAsParameter2() throws Exception { + " ghi\"\"\");\n" + " }\n" + "}") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertTextBlockToString.class) .findWarning("2:27-2:30:hint:" + Bundle.ERR_ConvertTextBlockToString()) .applyFix() diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToNestedRecordPatternTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToNestedRecordPatternTest.java index 28583a4a57de..566ef10c672f 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToNestedRecordPatternTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToNestedRecordPatternTest.java @@ -22,6 +22,8 @@ import org.netbeans.modules.java.hints.test.api.HintTest; import javax.lang.model.SourceVersion; +import static org.junit.Assume.assumeTrue; + /** * * @author mjayan @@ -33,9 +35,8 @@ public ConvertToNestedRecordPatternTest(String name) { } public void testSimple() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Rect(ColoredPoint upperLeft,ColoredPoint lr) {}\n" @@ -50,8 +51,7 @@ public void testSimple() throws Exception { + " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToNestedRecordPattern.class) .findWarning("7:25-7:63:verifier:" + Bundle.ERR_ConvertToNestedRecordPattern()) .applyFix() @@ -71,9 +71,8 @@ public void testSimple() throws Exception { } public void testRecordNameUsed() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Rect(ColoredPoint upperLeft,ColoredPoint lr) {}\n" @@ -88,16 +87,14 @@ public void testRecordNameUsed() throws Exception { + " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToNestedRecordPattern.class) .assertWarnings(); } public void testNameClash() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Rect(ColoredPoint upperLeft,ColoredPoint lr) {}\n" @@ -119,8 +116,7 @@ public void testNameClash() throws Exception { + " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToNestedRecordPattern.class) .findWarning("7:25-7:63:verifier:Convert to nested record pattern") .applyFix() @@ -147,9 +143,8 @@ public void testNameClash() throws Exception { } public void testMultipleNested() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Rect(ColoredPoint upperLeft) {}\n" @@ -164,8 +159,7 @@ public void testMultipleNested() throws Exception { + " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToNestedRecordPattern.class) .findWarning("7:25-7:61:verifier:" + Bundle.ERR_ConvertToNestedRecordPattern()) .applyFix() @@ -185,9 +179,8 @@ public void testMultipleNested() throws Exception { } public void testUserVar() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Rect(ColoredPoint upperLeft,ColoredPoint lr,ColoredPoint ur) {}\n" @@ -204,8 +197,7 @@ public void testUserVar() throws Exception { + " }\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToNestedRecordPattern.class) .findWarning("7:25-7:112:verifier:" + Bundle.ERR_ConvertToNestedRecordPattern()) .applyFix() diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToRecordPatternTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToRecordPatternTest.java index 72cd50c080ce..a4b3a5e6ce99 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToRecordPatternTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToRecordPatternTest.java @@ -21,6 +21,7 @@ import org.netbeans.junit.NbTestCase; import org.netbeans.modules.java.hints.test.api.HintTest; import javax.lang.model.SourceVersion; +import static org.junit.Assume.assumeTrue; /** * @@ -33,9 +34,8 @@ public ConvertToRecordPatternTest(String name) { } public void testSimple() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Person(String name, String place){}\n" @@ -48,8 +48,7 @@ public void testSimple() throws Exception { + " return -1;\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToRecordPattern.class) .findWarning("4:8-4:10:verifier:" + Bundle.ERR_ConvertToRecordPattern()) .applyFix() @@ -58,7 +57,7 @@ public void testSimple() throws Exception { + "record Person(String name, String place){}\n" + "public class Test {\n" + " private int test(Object o) {\n" - + " if (o instanceof Person(String name, String place) p) {\n" + + " if (o instanceof Person(String name, String place)) {\n" + " return name.length();\n" + " }\n" + " return -1;\n" @@ -67,9 +66,8 @@ public void testSimple() throws Exception { } public void testDuplicateVarName() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Person(String name, int s){}\n" @@ -82,8 +80,7 @@ public void testDuplicateVarName() throws Exception { + " return -1;\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToRecordPattern.class) .findWarning("4:8-4:10:verifier:" + Bundle.ERR_ConvertToRecordPattern()) .applyFix() @@ -92,7 +89,7 @@ public void testDuplicateVarName() throws Exception { + "record Person(String name, int s){}\n" + "public class Test {\n" + " private int test(Object s) {\n" - + " if (s instanceof Person(String name, int s1) p) {\n" + + " if (s instanceof Person(String name, int s1)) {\n" + " return name.length();\n" + " }\n" + " return -1;\n" @@ -101,9 +98,8 @@ public void testDuplicateVarName() throws Exception { } public void testUsingUserVar() throws Exception { - if (!isRecordClassPresent()) { - return; - } + assumeTrue(isRecordClassPresent()); + assumeTrue(SourceVersion.latest().ordinal() >= 21); HintTest.create() .input("package test;\n" + "record Person(String name, int s){}\n" @@ -116,8 +112,7 @@ public void testUsingUserVar() throws Exception { + " return -1;\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) - .options("--enable-preview") + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToRecordPattern.class) .findWarning("4:8-4:10:verifier:" + Bundle.ERR_ConvertToRecordPattern()) .applyFix() @@ -126,7 +121,7 @@ public void testUsingUserVar() throws Exception { + "record Person(String name, int s){}\n" + "public class Test {\n" + " private int test(Object s) {\n" - + " if (s instanceof Person(String userName, int s1) p) {\n" + + " if (s instanceof Person(String userName, int s1)) {\n" + " return userName.length();\n" + " }\n" + " return -1;\n" diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java index 9289ec2ec40b..8b1720ab1219 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java @@ -41,7 +41,7 @@ public void testFixWorking() throws Exception { " \"}\");\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToTextBlock.class) .findWarning("3:30-3:37:verifier:" + Bundle.ERR_ConvertToTextBlock()) .applyFix() @@ -75,7 +75,7 @@ public void testNewLineAtEnd() throws Exception { " \"}\\n\");\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToTextBlock.class) .findWarning("3:30-3:37:verifier:" + Bundle.ERR_ConvertToTextBlock()) .applyFix() @@ -110,7 +110,7 @@ public void testNewLinesAtEnd() throws Exception { " \"}\\n\\n\");\n" + " }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToTextBlock.class) .findWarning("3:30-3:37:verifier:" + Bundle.ERR_ConvertToTextBlock()) .applyFix() @@ -144,7 +144,7 @@ public void testOnlyLiterals() throws Exception { " }\n" + " private int c() { return 0; }\n" + "}\n") - .sourceLevel(SourceVersion.latest().name()) + .sourceLevel(SourceVersion.latest().ordinal()) .run(ConvertToTextBlock.class) .assertWarnings(); } diff --git a/platform/o.n.core/test/unit/src/org/netbeans/core/CanProxyToLocalhostTest.java b/platform/o.n.core/test/unit/src/org/netbeans/core/CanProxyToLocalhostTest.java index 18ef6cabf0ec..6c4136ae8968 100644 --- a/platform/o.n.core/test/unit/src/org/netbeans/core/CanProxyToLocalhostTest.java +++ b/platform/o.n.core/test/unit/src/org/netbeans/core/CanProxyToLocalhostTest.java @@ -29,7 +29,6 @@ import java.util.Locale; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import org.netbeans.core.ProxySettings; import org.netbeans.junit.NbTestCase; import org.openide.util.Lookup; import org.openide.util.NbBundle; @@ -83,13 +82,13 @@ public void testProxyForLocalhost() { String staticNonProxyHosts = NbBundle.getMessage(ProxySettings.class, "StaticNonProxyHosts"); // NOI18N assertNotNull(staticNonProxyHosts); assertEquals("The default non proxy hosts", "", staticNonProxyHosts); - assertEquals("Connect TO_LOCALHOST provided by MyPS", "HTTP @ my.webcache:8080", selector.select(TO_LOCALHOST).get(0).toString()); + assertEquals("Connect TO_LOCALHOST provided by MyPS", "HTTP @ my.webcache/:8080", selector.select(TO_LOCALHOST).get(0).toString()); assertEquals("One call to my ps", 1, MY_PS.called); } public void testAlwaysProxyForNonLocalhost() { Locale.setDefault(Locale.US); - assertEquals("Connect TO_NB provided by MyPS", "HTTP @ my.webcache:8080", selector.select(TO_NB).get(0).toString()); + assertEquals("Connect TO_NB provided by MyPS", "HTTP @ my.webcache/:8080", selector.select(TO_NB).get(0).toString()); assertEquals("One call to my ps", 1, MY_PS.called); } diff --git a/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js b/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_01.js similarity index 52% rename from webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js rename to webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_01.js index cc2e957847d4..9014bb2b2575 100644 --- a/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js +++ b/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_01.js @@ -1,2 +1 @@ var x= Math. -var x=Math. diff --git a/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js.testIssue215777_01.completion b/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_01.js.testIssue215777_01.completion similarity index 100% rename from webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js.testIssue215777_01.completion rename to webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_01.js.testIssue215777_01.completion diff --git a/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_02.js b/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_02.js new file mode 100644 index 000000000000..e4c1f60fb5b3 --- /dev/null +++ b/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_02.js @@ -0,0 +1 @@ +var x=Math. diff --git a/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js.testIssue215777_02.completion b/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_02.js.testIssue215777_02.completion similarity index 98% rename from webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js.testIssue215777_02.completion rename to webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_02.js.testIssue215777_02.completion index d83304fab8c2..f0f5da242571 100644 --- a/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777.js.testIssue215777_02.completion +++ b/webcommon/javascript2.editor/test/unit/data/testfiles/completion/issue215777_02.js.testIssue215777_02.completion @@ -80,5 +80,4 @@ FIELD SQRT2: Number [PUBLIC, JS Platform FIELD caller: Function [PUBLIC] JS Platform FIELD length: Number [PUBLIC] JS Platform FIELD name: String [PUBLIC] JS Platform -FIELD var: Math [PUBLIC] issue215777.js VARIABLE arguments: Object [PUBLIC] JS Platform diff --git a/webcommon/javascript2.editor/test/unit/src/org/netbeans/modules/javascript2/editor/JsCodeCompletionGeneralTest.java b/webcommon/javascript2.editor/test/unit/src/org/netbeans/modules/javascript2/editor/JsCodeCompletionGeneralTest.java index 23d429f01679..111009235600 100644 --- a/webcommon/javascript2.editor/test/unit/src/org/netbeans/modules/javascript2/editor/JsCodeCompletionGeneralTest.java +++ b/webcommon/javascript2.editor/test/unit/src/org/netbeans/modules/javascript2/editor/JsCodeCompletionGeneralTest.java @@ -61,11 +61,11 @@ public void testIssue215861_02() throws Exception { } public void testIssue215777_01() throws Exception { - checkCompletion("testfiles/completion/issue215777.js", "var x= Math.^", false); + checkCompletion("testfiles/completion/issue215777_01.js", "var x= Math.^", false); } public void testIssue215777_02() throws Exception { - checkCompletion("testfiles/completion/issue215777.js", "var x=Math.^", false); + checkCompletion("testfiles/completion/issue215777_02.js", "var x=Math.^", false); } public void testIssue217100_01() throws Exception {