Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-247

Exception thrown if sources artifact does not contain sources

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 9.0
    • java - Editor
    • None

    Description

      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:

      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)
      

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              cowwoc Gili
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: