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

MethodHandleNatives dependency on java.sql.DriverManager

    XMLWordPrintable

Details

    Description

      An undesirable static dependency from java.lang.invoke.MethodHandleNatives to java.sql.DriverManager leads to the base module to depend on jdbc module.

      The implementation of the isCallerSensitive method will ultimately be replaced by checking a specific annotation rather than hardcoded list. This issue is filed to track this static dependency and may close it as a dup of the other issue if the new implementation of this method will be integrated soon into jdk8.

      src/share/classes/java/lang/invoke/MethodHandleNatives.java

      @@ -446,11 +446,11 @@
                   return defc == java.lang.Class.class;
               case "getConnection":
               case "getDriver":
               case "getDrivers":
               case "deregisterDriver":
      - return defc == java.sql.DriverManager.class;
      + return defc == getClass("java.sql.DriverManager");
               case "newUpdater":
                   if (defc == java.util.concurrent.atomic.AtomicIntegerFieldUpdater.class) return true;
                   if (defc == java.util.concurrent.atomic.AtomicLongFieldUpdater.class) return true;
                   if (defc == java.util.concurrent.atomic.AtomicReferenceFieldUpdater.class) return true;
                   break;

      @@ -480,6 +480,16 @@
               case "clearCache":
                   return defc == java.util.ResourceBundle.class;
               }
               return false;
           }
      +
      + // avoid static dependency to a class in other modules
      + private static Class<?> getClass(String cn) {
      + try {
      + return Class.forName(cn, false,
      + MethodHandleNatives.class.getClassLoader());
      + } catch (ClassNotFoundException e) {
      + throw new InternalError(e);
      + }
      + }
       }

      Attachments

        Activity

          People

            mchung Mandy Chung
            mchung Mandy Chung
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: