Gili created NETBEANS-247:
-----------------------------

             Summary: Exception thrown if sources artifact does not contain 
sources
                 Key: NETBEANS-247
                 URL: https://issues.apache.org/jira/browse/NETBEANS-247
             Project: NetBeans
          Issue Type: Bug
          Components: java - Editor
         Environment: Product Version: Apache NetBeans IDE Dev (Build 
incubator-netbeans-release-159-on-20180102)
Updates: Updates available
Java: 9.0.1; Java HotSpot(TM) 64-Bit Server VM 9.0.1+11
Runtime: Java(TM) SE Runtime Environment 9.0.1+11
System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev
            Reporter: Gili


It seems some people are publishing invalid artifacts to Maven Central and 
ignoring bug reports asking them to fix it ;)

When Netbeans encounters this (example below) it blows up. Let's see if we can 
improve our error handling.

Given:

                <dependency>
                        <groupId>com.pusher</groupId>
                        <artifactId>pusher-java-client</artifactId>
                        <version>1.6.0</version>
                </dependency>

If you download Sources and Javadoc from Maven central you will discover that 
the sources jar contains the javadoc and javadoc jar contains the sources. If 
you open the dependency in the Projects tab, expand the artifact, and click on 
any of the class files you will get the following exception:

{code}
java.lang.IllegalArgumentException: Compilation unit is not of SOURCE kind: 
"Authorizer.class"
        at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:161)
        at 
org.netbeans.modules.java.source.parsing.JavacParser.createJavacTask(JavacParser.java:873)
        at 
org.netbeans.modules.java.source.parsing.JavacParser.createJavacTask(JavacParser.java:727)
        at 
org.netbeans.modules.java.source.parsing.CompilationInfoImpl.getJavacTask(CompilationInfoImpl.java:374)
        at 
org.netbeans.modules.java.source.parsing.ClassParser.getResult(ClassParser.java:160)
        at 
org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:608)
        at 
org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:239)
        at 
org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:775)
        at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279)
        at 
org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
[catch] at 
org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
        at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at 
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
        at 
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
        at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
        at 
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
{code}

Expected behavior: Treat the file as if no sources are available (open the 
decompiled representation). Don't throw an exception.

Bonus points: Consider ignoring the artifact type and using the sources/javadoc 
regardless of where you find them. If, however, multiple JARs contain the 
sources or javadoc then favor the ones coming out of the "correct" type JAR.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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