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

(reflect) Confusing exception cause in Proxy.getProxyClass() method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 6u23
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      The Proxy.getProxyClass() method displays a confusing message when one of the parameter Class has been loaded from a different classLoader.

      For example, let's say I have 2 webapps (A and B), with the same jar (test.jar) which contains the class com.example.Test.
      If I call Proxy.getProxyClass(ClassLoaderOfA, Test), with "Test" loaded by B, I get an IllegalArgumentException with the message "Test is not visible by the classLoader". This is wrong : Test class is visible by the classLoader of A, because webapp A got the test.jar too.

      There is a 3 cases scenario here :
      1) The class is found, and loaded from the right classLoader --> Ok
      2) The class is found, but loaded from a different classLoader --> Tell the user that the class comes from another classLoader
      3) The class is not found --> Tell the user that the class is not visible by the classLoader

      JUSTIFICATION :
      Instead of saying that the class is not visible, it should be said that the given class comes from a different classLoader, and still throw an IllegalArgumentException.
      The actual message is wrong for end user comprehension, and misleading.

            liach Chen Liang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: