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

The java.beans.Statement.invoke() method handles 3-arg Class.forName incorrectly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • 8u40, 9
    • client-libs
    • b124
    • x86
    • other

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_40"
      Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Darwin Big-iMac.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64


      A DESCRIPTION OF THE PROBLEM :
      The java.beans.Statement.invoke() method treats Class.forName as a special case, but it does not distinguish between the 1-argument

         forName(String className)

      method and the 3-argument

         forName(String name, boolean initialize, ClassLoader loader)

      If you try to call the 3-argument one, it's treated like the 1-argument method and so the loader parameter is not used.

      The problem seems clear in the java.beans.Statement source code where it says:

      if (target == Class.class && methodName.equals("forName")) {
          return ClassFinder.resolveClass((String)arguments[0]);
      }

      http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/beans/Statement.java

      It's as if the author did not realise the 3-argument method existed.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      Attachments

        Activity

          People

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: