Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8186459

[JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 10
    • 9, 10
    • hotspot
    • b22

      CompilerToVM.lookupType() can throw a ClassNotFoundException but it doesn't document it. This prohibits catching the ClassNotFoundException outside for proper error handling as javac detects that the exception is never thrown from the try statement body. Catching all the exceptions outside, filtering out the ClassNotFoundException and rethrowing the others works with javac but it is problematic if using tools like findbugs.

      Here is a trace where a ClassNotFoundException is thrown if the method for which the annotation is requested has a type which is not present on the classpath:

      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at jdk.vm.ci.hotspot.CompilerToVM.lookupType(Native Method)
      at jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.lookupType(HotSpotJVMCIRuntime.java:369)
      at jdk.vm.ci.hotspot.HotSpotUnresolvedJavaType.resolve(HotSpotUnresolvedJavaType.java:89)
      at jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl.toJava(HotSpotResolvedJavaMethodImpl.java:577)
      at jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl.getAnnotation(HotSpotResolvedJavaMethodImpl.java:521)

            dnsimon Douglas Simon
            cstancu Codrut Stancu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: