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

Print this page
rev 10452 : imported patch lang-Typos


 492         } catch (ReflectiveOperationException ex) {
 493             Error err = new IncompatibleClassChangeError();
 494             throw initCauseFrom(err, ex);
 495         }
 496     }
 497 
 498     /**
 499      * Use best possible cause for err.initCause(), substituting the
 500      * cause for err itself if the cause has the same (or better) type.
 501      */
 502     static private Error initCauseFrom(Error err, Exception ex) {
 503         Throwable th = ex.getCause();
 504         if (err.getClass().isInstance(th))
 505            return (Error) th;
 506         err.initCause(th == null ? ex : th);
 507         return err;
 508     }
 509 
 510     /**
 511      * Is this method a caller-sensitive method?
 512      * I.e., does it call Reflection.getCallerClass or a similer method
 513      * to ask about the identity of its caller?
 514      */
 515     static boolean isCallerSensitive(MemberName mem) {
 516         if (!mem.isInvocable())  return false;  // fields are not caller sensitive
 517 
 518         return mem.isCallerSensitive() || canBeCalledVirtual(mem);
 519     }
 520 
 521     static boolean canBeCalledVirtual(MemberName mem) {
 522         assert(mem.isInvocable());
 523         Class<?> defc = mem.getDeclaringClass();
 524         switch (mem.getName()) {
 525         case "checkMemberAccess":
 526             return canBeCalledVirtual(mem, java.lang.SecurityManager.class);
 527         case "getContextClassLoader":
 528             return canBeCalledVirtual(mem, java.lang.Thread.class);
 529         }
 530         return false;
 531     }
 532 


 492         } catch (ReflectiveOperationException ex) {
 493             Error err = new IncompatibleClassChangeError();
 494             throw initCauseFrom(err, ex);
 495         }
 496     }
 497 
 498     /**
 499      * Use best possible cause for err.initCause(), substituting the
 500      * cause for err itself if the cause has the same (or better) type.
 501      */
 502     static private Error initCauseFrom(Error err, Exception ex) {
 503         Throwable th = ex.getCause();
 504         if (err.getClass().isInstance(th))
 505            return (Error) th;
 506         err.initCause(th == null ? ex : th);
 507         return err;
 508     }
 509 
 510     /**
 511      * Is this method a caller-sensitive method?
 512      * I.e., does it call Reflection.getCallerClass or a similar method
 513      * to ask about the identity of its caller?
 514      */
 515     static boolean isCallerSensitive(MemberName mem) {
 516         if (!mem.isInvocable())  return false;  // fields are not caller sensitive
 517 
 518         return mem.isCallerSensitive() || canBeCalledVirtual(mem);
 519     }
 520 
 521     static boolean canBeCalledVirtual(MemberName mem) {
 522         assert(mem.isInvocable());
 523         Class<?> defc = mem.getDeclaringClass();
 524         switch (mem.getName()) {
 525         case "checkMemberAccess":
 526             return canBeCalledVirtual(mem, java.lang.SecurityManager.class);
 527         case "getContextClassLoader":
 528             return canBeCalledVirtual(mem, java.lang.Thread.class);
 529         }
 530         return false;
 531     }
 532