[jira] [Comment Edited] (NETBEANS-2221) ClassCastException when try to open class from not opened module

2019-06-28 Thread Benjamin Asbach (JIRA)


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

Benjamin Asbach edited comment on NETBEANS-2221 at 6/28/19 4:01 PM:


I get the same kind of Exception when accessing a maven librays class in 
"Debugging" window or via "Go to Type"-Window.

!image-2019-06-28-17-59-00-372.png!


was (Author: asbachb):
I get the same kind of Exception when accessing a maven librays class in 
"Debugging" window.

!image-2019-06-28-17-59-00-372.png!

> ClassCastException when try to open class from not opened module
> 
>
> Key: NETBEANS-2221
> URL: https://issues.apache.org/jira/browse/NETBEANS-2221
> Project: NetBeans
>  Issue Type: Bug
>Affects Versions: 11.0
>Reporter: Tomas Huryn
>Priority: Major
> Attachments: image-2019-06-28-17-59-00-372.png
>
>
> When I try to open a class from project which has not been opened before I 
> get the exception:
> WARNING [org.openide.filesystems.Ordering]: Not all children in / marked with 
> the position attribute: 
> [org-netbeans-modules-lsp-client-bindings-HyperlinkProviderImpl.instance], 
> but some are: [HyperlinkProviderImpl.instance, 
> org-netbeans-modules-editor-url-HyperlinkImpl.instance]
> WARNING [org.netbeans.modules.parsing.impl.TaskProcessor]: 
> ParserManager.parse called in AWT event thread by: 
> org.netbeans.modules.java.classfile.CodeGenerator.generateCode(CodeGenerator.java:152)
> Even though the source level of  is set to: 11, java.util.zip.CRC32C cannot 
> be found on the system module path: 
> Changing source level to 1.8
> SEVERE [global]
> java.lang.ClassCastException: class com.sun.tools.javac.code.Type$ClassType 
> cannot be cast to class com.sun.tools.javac.code.Type$ErrorType 
> (com.sun.tools.javac.code.Type$ClassType and 
> com.sun.tools.javac.code.Type$ErrorType are in unnamed module of loader 
> org.netbeans.StandardModule$OneModuleClassLoader @4f09236a)
>     at 
> org.netbeans.modules.java.source.builder.TreeFactory.Type(TreeFactory.java:863)
>     at org.netbeans.api.java.source.TreeMaker.Type(TreeMaker.java:1119)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.computeAnnotationTree(CodeGenerator.java:449)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.computeMods(CodeGenerator.java:411)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.visitType(CodeGenerator.java:373)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.visitType(CodeGenerator.java:285)
>     at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:1473)
>     at 
> javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:106)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator.generateCode(CodeGenerator.java:275)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$1.run(CodeGenerator.java:232)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$1.run(CodeGenerator.java:152)
>     at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:672)
>     at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:662)
>     at 
> org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:501)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:586)
>     at 
> org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:130)
>     at 
> org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:114)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:181)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:178)
>     at 
> org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
>     at 
> org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335)
>     at 
> org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118)
>     at 
> org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:178)
>     at 
> org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:81)
>     at 
> org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:451)
>     at 
> org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:422)
>     at 
> org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:683)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator.generateCode(CodeGenerator.java:152)
>     at 
> 

[jira] [Comment Edited] (NETBEANS-2221) ClassCastException when try to open class from not opened module

2019-06-28 Thread Benjamin Asbach (JIRA)


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

Benjamin Asbach edited comment on NETBEANS-2221 at 6/28/19 3:59 PM:


I get the same kind of Exception when accessing a maven librays class in 
"Debugging" window.

!image-2019-06-28-17-59-00-372.png!


was (Author: asbachb):
I get the same Exception when accessing a maven librays class class in 
"Debugging" window.

!image-2019-06-28-17-59-00-372.png!

> ClassCastException when try to open class from not opened module
> 
>
> Key: NETBEANS-2221
> URL: https://issues.apache.org/jira/browse/NETBEANS-2221
> Project: NetBeans
>  Issue Type: Bug
>Affects Versions: 11.0
>Reporter: Tomas Huryn
>Priority: Major
> Attachments: image-2019-06-28-17-59-00-372.png
>
>
> When I try to open a class from project which has not been opened before I 
> get the exception:
> WARNING [org.openide.filesystems.Ordering]: Not all children in / marked with 
> the position attribute: 
> [org-netbeans-modules-lsp-client-bindings-HyperlinkProviderImpl.instance], 
> but some are: [HyperlinkProviderImpl.instance, 
> org-netbeans-modules-editor-url-HyperlinkImpl.instance]
> WARNING [org.netbeans.modules.parsing.impl.TaskProcessor]: 
> ParserManager.parse called in AWT event thread by: 
> org.netbeans.modules.java.classfile.CodeGenerator.generateCode(CodeGenerator.java:152)
> Even though the source level of  is set to: 11, java.util.zip.CRC32C cannot 
> be found on the system module path: 
> Changing source level to 1.8
> SEVERE [global]
> java.lang.ClassCastException: class com.sun.tools.javac.code.Type$ClassType 
> cannot be cast to class com.sun.tools.javac.code.Type$ErrorType 
> (com.sun.tools.javac.code.Type$ClassType and 
> com.sun.tools.javac.code.Type$ErrorType are in unnamed module of loader 
> org.netbeans.StandardModule$OneModuleClassLoader @4f09236a)
>     at 
> org.netbeans.modules.java.source.builder.TreeFactory.Type(TreeFactory.java:863)
>     at org.netbeans.api.java.source.TreeMaker.Type(TreeMaker.java:1119)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.computeAnnotationTree(CodeGenerator.java:449)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.computeMods(CodeGenerator.java:411)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.visitType(CodeGenerator.java:373)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$TreeBuilder.visitType(CodeGenerator.java:285)
>     at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:1473)
>     at 
> javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:106)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator.generateCode(CodeGenerator.java:275)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$1.run(CodeGenerator.java:232)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator$1.run(CodeGenerator.java:152)
>     at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:672)
>     at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:662)
>     at 
> org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:501)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:586)
>     at 
> org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:130)
>     at 
> org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:114)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:181)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:178)
>     at 
> org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
>     at 
> org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335)
>     at 
> org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118)
>     at 
> org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67)
>     at 
> org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:178)
>     at 
> org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:81)
>     at 
> org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:451)
>     at 
> org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:422)
>     at 
> org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:683)
>     at 
> org.netbeans.modules.java.classfile.CodeGenerator.generateCode(CodeGenerator.java:152)
>     at 
> 

[jira] [Comment Edited] (NETBEANS-2221) ClassCastException when try to open class from not opened module

2019-05-17 Thread Mark Herkrath (JIRA)


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

Mark Herkrath edited comment on NETBEANS-2221 at 5/17/19 8:34 AM:
--

I am running into the same issue all the time and have done some analysis:

Code of {{org.netbeans.modules.java.source.builder.TreeFactory}}, where the 
ClassCastException happens:
{code:java}
public ExpressionTree Type(TypeMirror type) {
Type t = (Type) type;
JCExpression tp;
switch (type.getKind()) {
...
case ERROR:
tp = make.at(NOPOS).Ident(((ErrorType) type).tsym.name);
break;
default:
return make.at(NOPOS).Type((Type)type);
}

return tp.setType(t);
}  {code}
The getKind() implementation of ClassType used to always return DECLARED. 
However since Java 11, the getKind() implementation of ClassType has been 
changed:
{code:java}
   @DefinedBy(Api.LANGUAGE_MODEL)
public TypeKind getKind() {
tsym.apiComplete();
return tsym.kind == TYP ? TypeKind.DECLARED : TypeKind.ERROR;
} {code}
See [http://hg.openjdk.java.net/jdk/jdk/rev/cc2673fa8c20] due to 
[https://bugs.openjdk.java.net/browse/JDK-8187950]

The same change was done as part of nb-java here: 
[https://hg.netbeans.org/main/nb-java-x/diff/cc2673fa8c20/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java],
 as part of [https://hg.netbeans.org/main/nb-java-x/rev/cc2673fa8c20].

As a result, the cast to ErrorType for getKind() == ERROR isn't always valid 
anymore, and may throw ClassCastExceptions like this one.

Could it be possible that the nb-java change is part of the nb-java used for 
NetBeans 11, but not yet for the version used for NetBeans 10? It's not clear 
to me which tags are used.


was (Author: herkrath):
I am running into the same issue all the time and have done some analysis:

Code of {{org.netbeans.modules.java.source.builder.TreeFactory}}, where the 
ClassCastException happens:
{code:java}
public ExpressionTree Type(TypeMirror type) {
Type t = (Type) type;
JCExpression tp;
switch (type.getKind()) {
...
case ERROR:
tp = make.at(NOPOS).Ident(((ErrorType) type).tsym.name);
break;
default:
return make.at(NOPOS).Type((Type)type);
}

return tp.setType(t);
}  {code}
The getKind() implementation of ClassType used to always return DECLARED. 
However since Java 11, the getKind() implementation of ClassType has been 
changed:
{code:java}
   @DefinedBy(Api.LANGUAGE_MODEL)
public TypeKind getKind() {
tsym.apiComplete();
return tsym.kind == TYP ? TypeKind.DECLARED : TypeKind.ERROR;
} {code}
See [http://hg.openjdk.java.net/jdk/jdk/rev/cc2673fa8c20] due to 
[https://bugs.openjdk.java.net/browse/JDK-8187950]

As a result, the cast to ErrorType for getKind() == ERROR isn't always valid 
anymore. The strange thing is that I get the same error with Java 8u212 by 
Oracle (i.e. NB is running with that version and the Java version of my project 
is also set accordingly). Maybe it was back-ported but it's not clear to me if 
their com.sun.tools sources are publicly accessible somewhere. I don't see that 
change in the Java 8 release notes. Alternatively, NetBeans is using Java 11 
for de-compilation for whatever reason. I have at least added it as a Java 
Platform.

> ClassCastException when try to open class from not opened module
> 
>
> Key: NETBEANS-2221
> URL: https://issues.apache.org/jira/browse/NETBEANS-2221
> Project: NetBeans
>  Issue Type: Bug
>Affects Versions: 11.0
>Reporter: Tomas Huryn
>Priority: Major
>
> When I try to open a class from project which has not been opened before I 
> get the exception:
> WARNING [org.openide.filesystems.Ordering]: Not all children in / marked with 
> the position attribute: 
> [org-netbeans-modules-lsp-client-bindings-HyperlinkProviderImpl.instance], 
> but some are: [HyperlinkProviderImpl.instance, 
> org-netbeans-modules-editor-url-HyperlinkImpl.instance]
> WARNING [org.netbeans.modules.parsing.impl.TaskProcessor]: 
> ParserManager.parse called in AWT event thread by: 
> org.netbeans.modules.java.classfile.CodeGenerator.generateCode(CodeGenerator.java:152)
> Even though the source level of  is set to: 11, java.util.zip.CRC32C cannot 
> be found on the system module path: 
> Changing source level to 1.8
> SEVERE [global]
> java.lang.ClassCastException: class com.sun.tools.javac.code.Type$ClassType 
> cannot be cast to class com.sun.tools.javac.code.Type$ErrorType 
> (com.sun.tools.javac.code.Type$ClassType and 
>