[ 
https://issues.apache.org/jira/browse/NETBEANS-6349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17469742#comment-17469742
 ] 

Jaroslav Tulach edited comment on NETBEANS-6349 at 1/6/22, 7:23 AM:
--------------------------------------------------------------------

The problem with CharBuffer.flip() can easily be fixed by downcasting to 
{{Buffer}} first like:
{code:java}
netbeans$ git diff
diff --git 
a/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
 
b/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
index dcc5c286ad24..1208cf76dbb5 100644
--- 
a/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
+++ 
b/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
@@ -44,6 +44,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLEncoder;
+import java.nio.Buffer;
 import java.nio.CharBuffer;
 import java.nio.channels.CompletionHandler;
 import java.nio.charset.Charset;
@@ -513,7 +514,9 @@ public class FileObjects {
             return new MemoryFileObject(pkgStr, nameStr, uri, lastModified, 
CharBuffer.wrap( content ) );
         }
         else {
-            return new MemoryFileObject(pkgStr, nameStr, uri, lastModified, 
(CharBuffer)CharBuffer.allocate( length + 1 ).append( content ).append( ' ' 
).flip() );
+            Buffer buf = CharBuffer.allocate( length + 1 ).append( content 
).append( ' ' );
+            CharBuffer flipped = (CharBuffer) buf.flip();
+            return new MemoryFileObject(pkgStr, nameStr, uri, lastModified, 
flipped);
         }
     }
 {code}
feel free to apply the fix where needed. Thank you.


was (Author: jtulach):
The problem with {{CharBuffer.flip() }}can easily be fixed with:
{code:java}
netbeans$ git diff
diff --git 
a/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
 
b/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
index dcc5c286ad24..1208cf76dbb5 100644
--- 
a/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
+++ 
b/java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
@@ -44,6 +44,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLEncoder;
+import java.nio.Buffer;
 import java.nio.CharBuffer;
 import java.nio.channels.CompletionHandler;
 import java.nio.charset.Charset;
@@ -513,7 +514,9 @@ public class FileObjects {
             return new MemoryFileObject(pkgStr, nameStr, uri, lastModified, 
CharBuffer.wrap( content ) );
         }
         else {
-            return new MemoryFileObject(pkgStr, nameStr, uri, lastModified, 
(CharBuffer)CharBuffer.allocate( length + 1 ).append( content ).append( ' ' 
).flip() );
+            Buffer buf = CharBuffer.allocate( length + 1 ).append( content 
).append( ' ' );
+            CharBuffer flipped = (CharBuffer) buf.flip();
+            return new MemoryFileObject(pkgStr, nameStr, uri, lastModified, 
flipped);
         }
     }
 {code}
feel free to apply the fix where needed. Thank you.

> Recent builds of the module responsible for java source parsing break BC to 
> JDK 8
> ---------------------------------------------------------------------------------
>
>                 Key: NETBEANS-6349
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-6349
>             Project: NetBeans
>          Issue Type: Bug
>          Components: editor - Parsing & Indexing
>    Affects Versions: 12.5, 12.6
>            Reporter: Thomas Schapitz
>            Assignee: Jaroslav Tulach
>            Priority: Critical
>
> There are 6 linked Issues, that all follow a common pattern, pointing to a 
> common cause:
>  * They are accompanied by an java.lang.NoSuchMethodError: 
> java.nio.CharBuffer.flip()Ljava/nio/CharBuffer;
>  * The users indicate, they are running NB 12.5+ with JDK8
>  * The errors occur during parsing.
> Sure enough, JDK 8 hasn't 
> java.nio.CharBuffer.flip()Ljava/nio/{*}+CharBuffer+{*},
> it has only java.nio.CharBuffer.flip()Ljava/nio/{+}*Buffer,*{+} which it 
> inherits from Buffer.
> Which means: the Module in question has obviously been compiled against a 
> library more recent then JDK8, at least JDK9, which has this method.
>  
> Consequences:
> This and the 6 linked issues will automatically be fixed with the rollout of 
> NB 13, which will require JDK 11 as prerequisite anyway.
> In the mean time, users may work around the problem, by immediately switching 
> to JDK 9+ when executing Netbeans. Note that they should still be able to 
> develop and build for JDKs 8 an prior.  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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

Reply via email to