mbien commented on code in PR #7019:
URL: https://github.com/apache/netbeans/pull/7019#discussion_r1473590559


##########
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

Review Comment:
   luckily nothing seems to be using test case ordering: 
https://github.com/search?q=repo%3Aapache%2Fnetbeans%20NbTestCase.order&type=code
   
   so I haven't bothered to fix it.



##########
java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToRecordPatternTest.java:
##########
@@ -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"

Review Comment:
   @lahodaj i think the tests were wrong? This doesn't seem to be a valid 
syntax when it also includes the field name.
   
   Another side effect of this PR is that more tests are now active.



##########
java/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java:
##########
@@ -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;
     }

Review Comment:
   some tests used `SourceVersion.latest().name()` as source level which would 
be the full enum name. This would be quietly ignored and cause weird issues.
   
   The expected format is now enforced and the tests were fixed which used it 
wrong.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to