You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/11/16 16:07:35 UTC

[GitHub] [netbeans] sdedic opened a new pull request, #4975: Test bugfixes: preparation for GH action migration

sdedic opened a new pull request, #4975:
URL: https://github.com/apache/netbeans/pull/4975

   A follow-up to #4921. 
   
   The most important fix is a fix to `nbjavac` task that prevents classes like `$JsCallback$` and similar to be deleted just before an incremental compilation because they are considered inner classes (without a matching outer class).
   
   I've added additional logging to both server and client, because some thrown errors are wrapped into uninformative "Internal error". Added possibility to log-trace LSP messages (enabled by System property)
   
   
   I've cleaned up the test a little:
   - the exception about missing Groovy support turned into a WARNING line, if the client demands Groovy enabled, but it is simply not available. Other Reflective exceptions show stacktrace.
   - fixed error that manifested by a print about 'not normalized' license template filename/path
   - suppressed SocketClosed exceptions in test output
   - fixed potential CNFE when running on JDK11: Truffle could not access `sun.misc.Unsafe` during script engine initialization
   


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024509891


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   i have also an older JMH benchmark to offer:
   ```java
   @BenchmarkMode(Mode.AverageTime)
   @OutputTimeUnit(TimeUnit.NANOSECONDS)
   @Warmup(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
   @Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
   @Fork(1)
   @State(Scope.Benchmark)
   public class ConcatJMH {
   
       int i = 0;
   
       @Setup(Iteration)
       public void setup() {
           i = 0;
       }
   
       @Benchmark
       public void chain(Blackhole bh) {
           StringBuilder sb = new StringBuilder();
           sb.append("a");
           sb.append("[").append(i).append("]");
           sb.append("c");
           bh.consume(sb.toString());
       }
   
       @Benchmark
       public void mix(Blackhole bh) {
           StringBuilder sb = new StringBuilder();
           sb.append("a");
           sb.append("["+i+"]");
           sb.append("c");
           bh.consume(sb.toString());
       }
   
       @Benchmark
       public void plus(Blackhole bh) {
           bh.consume("a"+"["+i+"]"+"c");
       }
   
       @Benchmark
       public void concat(Blackhole bh) {
           bh.consume("a".concat("[").concat(String.valueOf(i)).concat("]").concat("c"));
       }
   
       public static void main(String[] args) throws RunnerException {
           
           Options opt = new OptionsBuilder()
                   .include(ConcatJMH.class.getSimpleName())
                   .resultFormat(ResultFormatType.JSON)
                   .result("results/"+ConcatJMH.class.getSimpleName()+".json")
                   .build();
   
           new Runner(opt).run();
   
       }
   }
   ```
   results on JDK 19:
   ```
   [stdout] Benchmark         Mode  Cnt   Score    Error  Units
   [stdout] ConcatJMH.chain   avgt    5   8.471 ±  2.516  ns/op
   [stdout] ConcatJMH.concat  avgt    5  13.055 ± 18.248  ns/op
   [stdout] ConcatJMH.mix     avgt    5  20.502 ±  9.329  ns/op
   [stdout] ConcatJMH.plus    avgt    5   5.342 ±  1.755  ns/op
   ```
   
   good old '+' wins hands down :)



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
lbownik commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024228966


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");
+                // no inner class' filename may begin directly with '$', it must be preceded by an outer class' name.
+                if (!enclosing.isFile()) {
+                    File enclosed = new File(d, clazz);
+                    log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);

Review Comment:
   since "verbose" level is almost always off, putting a guarding if statement will almost always avoid string concatenation of this message.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
lbownik commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024304058


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   As far as I know the "+" operator is implemented with StringBuilder underneath (complier generates this code). so at least two allocations are required (one for StringBuilder internal buffer and another then its "toString" method is called.
   on top of that we have a loop executed every time text is appended to StringBuilder and one look then its toString method is called.
   in case of String.concat method only one allocation for the new string is needed and only one loop which copies characters to newly allocated string
   
   of course the compiler may actually implement this specific case using String.concat underneath and I may simply be not aware of this.
   
   anyway if performance is irrelevant, ignore this comment



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024407861


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   Let's have some fun. I was curious, so I wrote a dumb testcase:
   ```
           long n1 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index) + ".class";
               A[0] = x;
           }
           long n2 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index).concat(".class");
               A[0] = x;
           }
           long n3 = System.nanoTime();
           
           System.err.println("First: " + (n2 - n1));
           System.err.println("Second: " + (n3 - n2));
   ```
   
   What was funy was the result:
   ```
   First:  3339608014
   Second: 3703034326
   ```
   (Oracle JDK11. Dummy assignments, so it would be harder for VM to optimize the entire concat out to /dev/zero)



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
lbownik commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024303058


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");
+                // no inner class' filename may begin directly with '$', it must be preceded by an outer class' name.
+                if (!enclosing.isFile()) {
+                    File enclosed = new File(d, clazz);
+                    log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
+                    if (!enclosed.delete()) {
+                        throw new BuildException("could not delete " + enclosed, getLocation());

Review Comment:
   As far as I know the "+" operator is implemented with StringBuilder underneath (complier generates this code). so at least two allocations are required (one for StringBuilder internal buffer and another then its "toString" method is called. 
   on top of that we have a loop executed every time text is appended to StringBuilder and one look then its toString method is called.
   in case of String.concat method only one allocation for the new string is needed and only one loop which copies characters to newly allocated string
   
   of course the compiler may actually implement this specific case using String.concat underneath and I may simply be not aware of this.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
mbien commented on PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#issuecomment-1322550163

   lets merge this this week so that we can finish up the migration PR and open it for review. Travis will end support for open source projects, apache projects have to migrate before the end of this year.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
lbownik commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024230974


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");
+                // no inner class' filename may begin directly with '$', it must be preceded by an outer class' name.
+                if (!enclosing.isFile()) {
+                    File enclosed = new File(d, clazz);
+                    log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
+                    if (!enclosed.delete()) {
+                        throw new BuildException("could not delete " + enclosed, getLocation());

Review Comment:
   "could not delete ".concat(enclosed.toString()) will avoid one allocation and one loop



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024407861


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   Let's have some fun. I was curious, so I wrote a dumb testcase:
   ```
           long n1 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index) + ".class";
               A[0] = x;
           }
           long n2 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index).concat(".class");
               A[0] = x;
           }
           long n3 = System.nanoTime();
           
           System.err.println("First: " + (n2 - n1));
           System.err.println("Second: " + (n3 - n2));
   ```
   
   What was funy was the result:
   ```
   First:      3339608014
   Second: 3703034326
   ```
   



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024231651


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");
+                // no inner class' filename may begin directly with '$', it must be preceded by an outer class' name.
+                if (!enclosing.isFile()) {
+                    File enclosed = new File(d, clazz);
+                    log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);

Review Comment:
   this is a NB internal build tool. There are not really performance concerns here. Readability > efficiency in this case.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024308991


##########
nbbuild/templates/projectized.xml:
##########
@@ -123,7 +123,7 @@
         </condition>
     </target>
     <target name="-init-bootclasspath-prepend-run9" depends="-init-bootclasspath-prepend-compile" if="have-jdk-1.9">
-        <condition property="test.bootclasspath.prepend.args" value="--limit-modules=java.base,java.logging,java.xml,java.prefs,java.desktop,java.management,java.instrument,jdk.zipfs,java.scripting,java.naming,jdk.jdi">
+        <condition property="test.bootclasspath.prepend.args" value="--limit-modules=java.base,java.logging,java.xml,java.prefs,java.desktop,java.management,java.instrument,jdk.zipfs,java.scripting,java.naming,jdk.jdi,jdk.unsupported">

Review Comment:
   excellent! This means we have another job which could run on JDK 11+ (e.g in a matrix).



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024239441


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   > clazz.substring(0, i).concat(".class") will avoid one allocation and one loop
   
   I can't see that - could you explain, especially the "loop" part ? 



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024319574


##########
nbbuild/templates/projectized.xml:
##########
@@ -123,7 +123,7 @@
         </condition>
     </target>
     <target name="-init-bootclasspath-prepend-run9" depends="-init-bootclasspath-prepend-compile" if="have-jdk-1.9">
-        <condition property="test.bootclasspath.prepend.args" value="--limit-modules=java.base,java.logging,java.xml,java.prefs,java.desktop,java.management,java.instrument,jdk.zipfs,java.scripting,java.naming,jdk.jdi">
+        <condition property="test.bootclasspath.prepend.args" value="--limit-modules=java.base,java.logging,java.xml,java.prefs,java.desktop,java.management,java.instrument,jdk.zipfs,java.scripting,java.naming,jdk.jdi,jdk.unsupported">

Review Comment:
   Not really - there are still some failing tests, I asked @dbalek  for an assistance as the failure seems to be deeply burried in javac binding infrastructure. But it's definitely a step forward.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic merged pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic merged PR #4975:
URL: https://github.com/apache/netbeans/pull/4975


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024509891


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   i have also an older JMH benchmark to offer:
   ```java
   @BenchmarkMode(Mode.AverageTime)
   @OutputTimeUnit(TimeUnit.NANOSECONDS)
   @Warmup(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
   @Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
   @Fork(1)
   @State(Scope.Benchmark)
   public class ConcatJMH {
   
       int i = 0;
   
       @Setup(Iteration)
       public void setup() {
           i = 0;
       }
   
       @Benchmark
       public void chain(Blackhole bh) {
           StringBuilder sb = new StringBuilder();
           sb.append("a");
           sb.append("[").append(i).append("]");
           sb.append("c");
           bh.consume(sb.toString());
       }
   
       @Benchmark
       public void mix(Blackhole bh) {
           StringBuilder sb = new StringBuilder();
           sb.append("a");
           sb.append("["+i+"]");
           sb.append("c");
           bh.consume(sb.toString());
       }
   
       @Benchmark
       public void plus(Blackhole bh) {
           bh.consume("a"+"["+i+"]"+"c");
       }
   
       @Benchmark
       public void concat(Blackhole bh) {
           bh.consume("a".concat("[").concat(String.valueOf(i)).concat("]").concat("c"));
       }
   
       public static void main(String[] args) throws RunnerException {
           
           Options opt = new OptionsBuilder()
                   .include(ConcatJMH.class.getSimpleName())
                   .resultFormat(ResultFormatType.JSON)
                   .result("results/"+ConcatJMH.class.getSimpleName()+".json")
                   .build();
   
           new Runner(opt).run();
   
       }
   }
   ```
   results on JDK 19:
   ```
       Benchmark          Mode  Cnt   Score   Error  Units
       ConcatJMH.chain    avgt    5  11.478 ± 0.266  ns/op
       ConcatJMH.mix      avgt    5  19.877 ± 0.301  ns/op
       ConcatJMH.concat   avgt    5   8.388 ± 0.179  ns/op
   ```
   
   good old '+' wins hands down :)



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024407861


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   Let's have some fun. I was curious, so I wrote a dumb testcase:
   ```
           long n1 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index) + ".class";
               A[0] = x;
           }
           long n2 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index).concat(".class");
               A[0] = x;
           }
           long n3 = System.nanoTime();
           
           System.err.println("First: " + (n2 - n1));
           System.err.println("Second: " + (n3 - n2));
   ```
   
   What was funy was the result:
   ```
   First:  3339608014
   Second: 3703034326
   ```
   (Oracle JDK11)



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024239441


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   > clazz.substring(0, i).concat(".class") will avoid one allocation and one loop
   
   I can't see that - could you please elaborate, especially the "loop" part ? 



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
lbownik commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024231922


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   clazz.substring(0, i).concat(".class") will avoid one allocation and one loop



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024323601


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   `clazz.substring(0, i).concat(".class")` would be fine with me since its a low impact change readability wise (but I don't think it is necessary ;)).
   
   This code would use invoke dynamic as soon we decide to rise the language level above 8. You can't do much faster than `+` in modern java. It already knows all the tricks.
   
   There are some exceptions when SB will be faster e.g if you build something in a loop, esp if you can pre-allocate it. But for simple cases: don't worry about `+`.
   
   here a talk by Heinz Kabutz which goes into details:
   https://www.youtube.com/watch?v=z3yu1kjtcok



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024407861


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   Let's have some fun. I was curious, so I wrote a dumb testcase:
   ```
           long n1 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index) + ".class";
               A[0] = x;
           }
           long n2 = System.nanoTime();
           for (long i = 0; i < 100000000L; i++) {
               int index = S.indexOf('$');
               String x = S.substring(0, index).concat(".class");
               A[0] = x;
           }
           long n3 = System.nanoTime();
           
           System.err.println("First: " + (n2 - n1));
           System.err.println("Second: " + (n3 - n2));
   ```
   
   What was funy was the result:
   ```
   First:  3339608014
   Second: 3703034326
   ```
   (Oracle JDK11. Dummy assignments, so it would be harder for VM to optimize the entire concat out to /dev/null)



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #4975: Test bugfixes: preparation for GH action migration

Posted by GitBox <gi...@apache.org>.
lbownik commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024521350


##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
                 continue;
             }
             int i = clazz.indexOf('$');
-            File enclosing = new File(d, clazz.substring(0, i) + ".class");
-            if (!enclosing.isFile()) {
-                File enclosed = new File(d, clazz);
-                log(clazz + " will be deleted since " + enclosing.getName() + " is missing", Project.MSG_VERBOSE);
-                if (!enclosed.delete()) {
-                    throw new BuildException("could not delete " + enclosed, getLocation());
+            // ignore filenames that start right with '$' (separatorChar preceded), these could not be inner classes.
+            if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+                File enclosing = new File(d, clazz.substring(0, i) + ".class");

Review Comment:
   thanks for the feedback, I learned something new today :) 
   it's good that the most compact form of concatenation is finally the most performant one
   let's hope NetBeans doesn't get stuck with java8 forever ;)



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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