src/share/classes/java/lang/invoke/MethodHandleStatics.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/share/classes/java/lang/invoke

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

Print this page
rev 9490 : 8037210: Get rid of char-based descriptions 'J' of basic types
Reviewed-by: jrose, ?


  48     static final Integer COMPILE_THRESHOLD;
  49     static {
  50         final Object[] values = { false, false, false, false, null };
  51         AccessController.doPrivileged(new PrivilegedAction<Void>() {
  52                 public Void run() {
  53                     values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
  54                     values[1] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES");
  55                     values[2] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_INTERPRETER");
  56                     values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE");
  57                     values[4] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD");
  58                     return null;
  59                 }
  60             });
  61         DEBUG_METHOD_HANDLE_NAMES = (Boolean) values[0];
  62         DUMP_CLASS_FILES          = (Boolean) values[1];
  63         TRACE_INTERPRETER         = (Boolean) values[2];
  64         TRACE_METHOD_LINKAGE      = (Boolean) values[3];
  65         COMPILE_THRESHOLD         = (Integer) values[4];
  66     }
  67 










  68     /*non-public*/ static String getNameString(MethodHandle target, MethodType type) {
  69         if (type == null)
  70             type = target.type();
  71         MemberName name = null;
  72         if (target != null)
  73             name = target.internalMemberName();
  74         if (name == null)
  75             return "invoke" + type;
  76         return name.getName() + type;
  77     }
  78 
  79     /*non-public*/ static String getNameString(MethodHandle target, MethodHandle typeHolder) {
  80         return getNameString(target, typeHolder == null ? (MethodType) null : typeHolder.type());
  81     }
  82 
  83     /*non-public*/ static String getNameString(MethodHandle target) {
  84         return getNameString(target, (MethodType) null);
  85     }
  86 
  87     /*non-public*/ static String addTypeString(Object obj, MethodHandle target) {
  88         String str = String.valueOf(obj);
  89         if (target == null)  return str;
  90         int paren = str.indexOf('(');
  91         if (paren >= 0) str = str.substring(0, paren);
  92         return str + target.type();
  93     }
  94 
  95     // handy shared exception makers (they simplify the common case code)



  96     /*non-public*/ static InternalError newInternalError(String message, Throwable cause) {
  97         return new InternalError(message, cause);
  98     }
  99     /*non-public*/ static InternalError newInternalError(Throwable cause) {
 100         return new InternalError(cause);
 101     }
 102     /*non-public*/ static RuntimeException newIllegalStateException(String message) {
 103         return new IllegalStateException(message);
 104     }
 105     /*non-public*/ static RuntimeException newIllegalStateException(String message, Object obj) {
 106         return new IllegalStateException(message(message, obj));
 107     }
 108     /*non-public*/ static RuntimeException newIllegalArgumentException(String message) {
 109         return new IllegalArgumentException(message);
 110     }
 111     /*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj) {
 112         return new IllegalArgumentException(message(message, obj));
 113     }
 114     /*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj, Object obj2) {
 115         return new IllegalArgumentException(message(message, obj, obj2));


  48     static final Integer COMPILE_THRESHOLD;
  49     static {
  50         final Object[] values = { false, false, false, false, null };
  51         AccessController.doPrivileged(new PrivilegedAction<Void>() {
  52                 public Void run() {
  53                     values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
  54                     values[1] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES");
  55                     values[2] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_INTERPRETER");
  56                     values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE");
  57                     values[4] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD");
  58                     return null;
  59                 }
  60             });
  61         DEBUG_METHOD_HANDLE_NAMES = (Boolean) values[0];
  62         DUMP_CLASS_FILES          = (Boolean) values[1];
  63         TRACE_INTERPRETER         = (Boolean) values[2];
  64         TRACE_METHOD_LINKAGE      = (Boolean) values[3];
  65         COMPILE_THRESHOLD         = (Integer) values[4];
  66     }
  67 
  68     /** Tell if any of the debugging switches are turned on.
  69      *  If this is the case, it is reasonable to perform extra checks or save extra information.
  70      */
  71     /*non-public*/ static boolean debugEnabled() {
  72         return (DEBUG_METHOD_HANDLE_NAMES |
  73                 DUMP_CLASS_FILES |
  74                 TRACE_INTERPRETER |
  75                 TRACE_METHOD_LINKAGE);
  76     }
  77 
  78     /*non-public*/ static String getNameString(MethodHandle target, MethodType type) {
  79         if (type == null)
  80             type = target.type();
  81         MemberName name = null;
  82         if (target != null)
  83             name = target.internalMemberName();
  84         if (name == null)
  85             return "invoke" + type;
  86         return name.getName() + type;
  87     }
  88 
  89     /*non-public*/ static String getNameString(MethodHandle target, MethodHandle typeHolder) {
  90         return getNameString(target, typeHolder == null ? (MethodType) null : typeHolder.type());
  91     }
  92 
  93     /*non-public*/ static String getNameString(MethodHandle target) {
  94         return getNameString(target, (MethodType) null);
  95     }
  96 
  97     /*non-public*/ static String addTypeString(Object obj, MethodHandle target) {
  98         String str = String.valueOf(obj);
  99         if (target == null)  return str;
 100         int paren = str.indexOf('(');
 101         if (paren >= 0) str = str.substring(0, paren);
 102         return str + target.type();
 103     }
 104 
 105     // handy shared exception makers (they simplify the common case code)
 106     /*non-public*/ static InternalError newInternalError(String message) {
 107         return new InternalError(message);
 108     }
 109     /*non-public*/ static InternalError newInternalError(String message, Throwable cause) {
 110         return new InternalError(message, cause);
 111     }
 112     /*non-public*/ static InternalError newInternalError(Throwable cause) {
 113         return new InternalError(cause);
 114     }
 115     /*non-public*/ static RuntimeException newIllegalStateException(String message) {
 116         return new IllegalStateException(message);
 117     }
 118     /*non-public*/ static RuntimeException newIllegalStateException(String message, Object obj) {
 119         return new IllegalStateException(message(message, obj));
 120     }
 121     /*non-public*/ static RuntimeException newIllegalArgumentException(String message) {
 122         return new IllegalArgumentException(message);
 123     }
 124     /*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj) {
 125         return new IllegalArgumentException(message(message, obj));
 126     }
 127     /*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj, Object obj2) {
 128         return new IllegalArgumentException(message(message, obj, obj2));
src/share/classes/java/lang/invoke/MethodHandleStatics.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File