161. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:09 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

161.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\java\lang\invoke MethodHandleNatives.java Mon Jan 22 14:46:52 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\java\lang\invoke MethodHandleNatives.java Wed Sep 12 17:08:47 2018 UTC

161.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1078
Changed 1 2
Inserted 0 0
Removed 0 0

161.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

161.4 Active regular expressions

No regular expressions were active.

161.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 200 8, 2013, O racle and/ or its aff iliates. A ll rights  reserved.
  3    * DO NOT  ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER.
  4    *
  5    * This co de is free  software;  you can r edistribut e it and/o r modify i t
  6    * under t he terms o f the GNU  General Pu blic Licen se version  2 only, a s
  7    * publish ed by the  Free Softw are Founda tion.  Ora cle design ates this
  8    * particu lar file a s subject  to the "Cl asspath" e xception a s provided
  9    * by Orac le in the  LICENSE fi le that ac companied  this code.
  10    *
  11    * This co de is dist ributed in  the hope  that it wi ll be usef ul, but WI THOUT
  12    * ANY WAR RANTY; wit hout even  the implie d warranty  of MERCHA NTABILITY  or
  13    * FITNESS  FOR A PAR TICULAR PU RPOSE.  Se e the GNU  General Pu blic Licen se
  14    * version  2 for mor e details  (a copy is  included  in the LIC ENSE file  that
  15    * accompa nied this  code).
  16    *
  17    * You sho uld have r eceived a  copy of th e GNU Gene ral Public  License v ersion
  18    * 2 along  with this  work; if  not, write  to the Fr ee Softwar e Foundati on,
  19    * Inc., 5 1 Franklin  St, Fifth  Floor, Bo ston, MA 0 2110-1301  USA.
  20    *
  21    * Please  contact Or acle, 500  Oracle Par kway, Redw ood Shores , CA 94065  USA
  22    * or visi t www.orac le.com if  you need a dditional  informatio n or have  any
  23    * questio ns.
  24    */
  25  
  26   package ja va.lang.in voke;
  27  
  28   import jav a.lang.inv oke.Method Handles.Lo okup;
  29   import jav a.lang.ref lect.Field ;
  30   import sta tic java.l ang.invoke .MethodHan dleNatives .Constants .*;
  31   import sta tic java.l ang.invoke .MethodHan dleStatics .*;
  32   import sta tic java.l ang.invoke .MethodHan dles.Looku p.IMPL_LOO KUP;
  33  
  34   /**
  35    * The JVM  interface  for the m ethod hand les packag e is all h ere.
  36    * This is  an interf ace intern al and pri vate to an  implement ation of J SR 292.
  37    * <em>Thi s class is  not part  of the JSR  292 stand ard.</em>
  38    * @author  jrose
  39    */
  40   class Meth odHandleNa tives {
  41  
  42       privat e MethodHa ndleNative s() { } //  static on ly
  43  
  44       /// Me mberName s upport
  45  
  46       static  native vo id init(Me mberName s elf, Objec t ref);
  47       static  native vo id expand( MemberName  self);
  48       static  native Me mberName r esolve(Mem berName se lf, Class< ?> caller)  throws Li nkageError , ClassNot FoundExcep tion;
  49       static  native in t getMembe rs(Class<? > defc, St ring match Name, Stri ng matchSi g,
  50                int matc hFlags, Cl ass<?> cal ler, int s kip, Membe rName[] re sults);
  51  
  52       /// Fi eld layout  queries p arallel to  sun.misc. Unsafe:
  53       static  native lo ng objectF ieldOffset (MemberNam e self);   // e.g., r eturns vmi ndex
  54       static  native lo ng staticF ieldOffset (MemberNam e self);   // e.g., r eturns vmi ndex
  55       static  native Ob ject stati cFieldBase (MemberNam e self);   // e.g., r eturns cla zz
  56       static  native Ob ject getMe mberVMInfo (MemberNam e self);   // returns  {vmindex, vmtarget}
  57  
  58       /// Me thodHandle  support
  59  
  60       /** Fe tch MH-rel ated JVM p arameter.
  61        *  wh ich=0 retr ieves Meth odHandlePu shLimit
  62        *  wh ich=1 retr ieves stac k slot pus h size (in  address u nits)
  63        */
  64       static  native in t getConst ant(int wh ich);
  65  
  66       static  final boo lean COUNT _GWT;
  67  
  68       /// Ca llSite sup port
  69  
  70       /** Te ll the JVM  that we n eed to cha nge the ta rget of a  CallSite.  */
  71       static  native vo id setCall SiteTarget Normal(Cal lSite site , MethodHa ndle targe t);
  72       static  native vo id setCall SiteTarget Volatile(C allSite si te, Method Handle tar get);
  73  
  74       privat e static n ative void  registerN atives();
  75       static  {
  76           re gisterNati ves();
  77           CO UNT_GWT                     = ge tConstant( Constants. GC_COUNT_G WT) != 0;
  78  
  79           //  The JVM c alls Metho dHandleNat ives.<clin it>.  Casc ade the <c linit> cal ls as need ed:
  80           Me thodHandle Impl.initS tatics();
  81       }
  82  
  83       // All  compile-t ime consta nts go her e.
  84       // The re is an o pportunity  to check  them again st the JVM 's idea of  them.
  85       static  class Con stants {
  86           Co nstants()  { } // sta tic only
  87           //  MethodHan dleImpl
  88           st atic final  int // fo r getConst ant
  89                    GC_C OUNT_GWT =  4,
  90                      GC_LAMBDA_ SUPPORT     
;
  91  
  92           //  MemberNam e
  93           //  The JVM u ses values  of -2 and  above for  vtable in dexes.
  94           //  Field val ues are si mple posit ive offset s.
  95           //  Ref: src/ share/vm/o ops/method Oop.hpp
  96           //  This valu e is negat ive enough  to avoid  such numbe rs,
  97           //  but not t oo negativ e.
  98           st atic final  int
  99                    MN_I S_METHOD            =  0x0001000 0, // meth od (not co nstructor)
  100                    MN_I S_CONSTRUC TOR      =  0x0002000 0, // cons tructor
  101                    MN_I S_FIELD             =  0x0004000 0, // fiel d
  102                    MN_I S_TYPE              =  0x0008000 0, // nest ed type
  103                    MN_C ALLER_SENS ITIVE    =  0x0010000 0, // @Cal lerSensiti ve annotat ion detect ed
  104                    MN_R EFERENCE_K IND_SHIFT  = 24, // r efKind
  105                    MN_R EFERENCE_K IND_MASK =  0x0F00000 0 >> MN_RE FERENCE_KI ND_SHIFT,
  106                    // T he SEARCH_ * bits are  not for M N.flags bu t for the  matchFlags  argument  of MHN.get Members:
  107                    MN_S EARCH_SUPE RCLASSES =  0x0010000 0,
  108                    MN_S EARCH_INTE RFACES   =  0x0020000 0;
  109  
  110           /* *
  111            *  Basic typ es as enco ded in the  JVM.  The se code va lues are n ot
  112            *  intended  for use ou tside this  class.  T hey are us ed as part  of
  113            *  a private  interface  between t he JVM and  this clas s.
  114            * /
  115           st atic final  int
  116                T_BOOLEA N  =  4,
  117                T_CHAR      =  5,
  118                T_FLOAT     =  6,
  119                T_DOUBLE    =  7,
  120                T_BYTE      =  8,
  121                T_SHORT     =  9,
  122                T_INT       = 10,
  123                T_LONG      = 11,
  124                T_OBJECT    = 12,
  125                //T_ARRA Y    = 13
  126                T_VOID      = 14,
  127                //T_ADDR ESS  = 15
  128                T_ILLEGA L  = 99;
  129  
  130           /* *
  131            *  Constant  pool entry  types.
  132            * /
  133           st atic final  byte
  134                CONSTANT _Utf8                  = 1,
  135                CONSTANT _Integer               = 3,
  136                CONSTANT _Float                 = 4,
  137                CONSTANT _Long                  = 5,
  138                CONSTANT _Double                = 6,
  139                CONSTANT _Class                 = 7,
  140                CONSTANT _String                = 8,
  141                CONSTANT _Fieldref              = 9,
  142                CONSTANT _Methodref             = 10,
  143                CONSTANT _Interface Methodref   = 11,
  144                CONSTANT _NameAndTy pe          = 12,
  145                CONSTANT _MethodHan dle         = 15,  //  JSR 292
  146                CONSTANT _MethodTyp e           = 16,  //  JSR 292
  147                CONSTANT _InvokeDyn amic        = 18,
  148                CONSTANT _LIMIT                 = 19;   / / Limit to  tags foun d in class files
  149  
  150           /* *
  151            *  Access mo difier fla gs.
  152            * /
  153           st atic final  char
  154                ACC_PUBL IC                  =  0x0001,
  155                ACC_PRIV ATE                 =  0x0002,
  156                ACC_PROT ECTED               =  0x0004,
  157                ACC_STAT IC                  =  0x0008,
  158                ACC_FINA L                   =  0x0010,
  159                ACC_SYNC HRONIZED            =  0x0020,
  160                ACC_VOLA TILE                =  0x0040,
  161                ACC_TRAN SIENT               =  0x0080,
  162                ACC_NATI VE                  =  0x0100,
  163                ACC_INTE RFACE               =  0x0200,
  164                ACC_ABST RACT                =  0x0400,
  165                ACC_STRI CT                  =  0x0800,
  166                ACC_SYNT HETIC               =  0x1000,
  167                ACC_ANNO TATION              =  0x2000,
  168                ACC_ENUM                     =  0x4000,
  169                // alias es:
  170                ACC_SUPE R                   =  ACC_SYNCH RONIZED,
  171                ACC_BRID GE                  =  ACC_VOLAT ILE,
  172                ACC_VARA RGS                 =  ACC_TRANS IENT;
  173  
  174           /* *
  175            *  Constant  pool refer ence-kind  codes, as  used by CO NSTANT_Met hodHandle  CP entries .
  176            * /
  177           st atic final  byte
  178                REF_NONE                       = 0,  // n ull value
  179                REF_getF ield                  = 1,
  180                REF_getS tatic                 = 2,
  181                REF_putF ield                  = 3,
  182                REF_putS tatic                 = 4,
  183                REF_invo keVirtual             = 5,
  184                REF_invo keStatic              = 6,
  185                REF_invo keSpecial             = 7,
  186                REF_newI nvokeSpeci al         = 8,
  187                REF_invo keInterfac e          = 9,
  188                REF_LIMI T                   =  10;
  189       }
  190  
  191       static  boolean r efKindIsVa lid(int re fKind) {
  192           re turn (refK ind > REF_ NONE && re fKind < RE F_LIMIT);
  193       }
  194       static  boolean r efKindIsFi eld(byte r efKind) {
  195           as sert(refKi ndIsValid( refKind));
  196           re turn (refK ind <= REF _putStatic );
  197       }
  198       static  boolean r efKindIsGe tter(byte  refKind) {
  199           as sert(refKi ndIsValid( refKind));
  200           re turn (refK ind <= REF _getStatic );
  201       }
  202       static  boolean r efKindIsSe tter(byte  refKind) {
  203           re turn refKi ndIsField( refKind) & & !refKind IsGetter(r efKind);
  204       }
  205       static  boolean r efKindIsMe thod(byte  refKind) {
  206           re turn !refK indIsField (refKind)  && (refKin d != REF_n ewInvokeSp ecial);
  207       }
  208       static  boolean r efKindIsCo nstructor( byte refKi nd) {
  209           re turn (refK ind == REF _newInvoke Special);
  210       }
  211       static  boolean r efKindHasR eceiver(by te refKind ) {
  212           as sert(refKi ndIsValid( refKind));
  213           re turn (refK ind & 1) ! = 0;
  214       }
  215       static  boolean r efKindIsSt atic(byte  refKind) {
  216           re turn !refK indHasRece iver(refKi nd) && (re fKind != R EF_newInvo keSpecial) ;
  217       }
  218       static  boolean r efKindDoes Dispatch(b yte refKin d) {
  219           as sert(refKi ndIsValid( refKind));
  220           re turn (refK ind == REF _invokeVir tual ||
  221                    refK ind == REF _invokeInt erface);
  222       }
  223       static  {
  224           fi nal int HR _MASK = (( 1 << REF_g etField) |
  225                                  ( 1 << REF_p utField) |
  226                                  ( 1 << REF_i nvokeVirtu al) |
  227                                  ( 1 << REF_i nvokeSpeci al) |
  228                                  ( 1 << REF_i nvokeInter face)
  229                                 );
  230           fo r (byte re fKind = RE F_NONE+1;  refKind <  REF_LIMIT;  refKind++ ) {
  231                assert(r efKindHasR eceiver(re fKind) ==  (((1<<refK ind) & HR_ MASK) != 0 )) : refKi nd;
  232           }
  233       }
  234       static  String re fKindName( byte refKi nd) {
  235           as sert(refKi ndIsValid( refKind));
  236           sw itch (refK ind) {
  237           ca se REF_get Field:           retu rn "getFie ld";
  238           ca se REF_get Static:          retu rn "getSta tic";
  239           ca se REF_put Field:           retu rn "putFie ld";
  240           ca se REF_put Static:          retu rn "putSta tic";
  241           ca se REF_inv okeVirtual :     retu rn "invoke Virtual";
  242           ca se REF_inv okeStatic:       retu rn "invoke Static";
  243           ca se REF_inv okeSpecial :     retu rn "invoke Special";
  244           ca se REF_new InvokeSpec ial:  retu rn "newInv okeSpecial ";
  245           ca se REF_inv okeInterfa ce:   retu rn "invoke Interface" ;
  246           de fault:                      retu rn "REF_?? ?";
  247           }
  248       }
  249  
  250       privat e static n ative int  getNamedCo n(int whic h, Object[ ] name);
  251       static  boolean v erifyConst ants() {
  252           Ob ject[] box  = { null  };
  253           fo r (int i =  0; ; i++)  {
  254                box[0] =  null;
  255                int vmva l = getNam edCon(i, b ox);
  256                if (box[ 0] == null )  break;
  257                String n ame = (Str ing) box[0 ];
  258                try {
  259                    Fiel d con = Co nstants.cl ass.getDec laredField (name);
  260                    int  jval = con .getInt(nu ll);
  261                    if ( jval == vm val)  cont inue;
  262                    Stri ng err = ( name+": JV M has "+vm val+" whil e Java has  "+jval);
  263                    if ( name.equal s("CONV_OP _LIMIT"))  {
  264                         System.err .println(" warning: " +err);
  265                         continue;
  266                    }
  267                    thro w new Inte rnalError( err);
  268                } catch  (NoSuchFie ldExceptio n | Illega lAccessExc eption ex)  {
  269                    Stri ng err = ( name+": JV M has "+vm val+" whic h Java doe s not defi ne");
  270                    // i gnore exot ic ops the  JVM cares  about; we  just wont  issue the m
  271                    //Sy stem.err.p rintln("wa rning: "+e rr);
  272                    cont inue;
  273                }
  274           }
  275           re turn true;
  276       }
  277       static  {
  278           as sert(verif yConstants ());
  279       }
  280  
  281       // Up- calls from  the JVM.
  282       // The se must NO T be publi c.
  283  
  284       /**
  285        * The  JVM is li nking an i nvokedynam ic instruc tion.  Cre ate a reif ied call s ite for it .
  286        */
  287       static  MemberNam e linkCall Site(Objec t callerOb j,
  288                                         Objec t bootstra pMethodObj ,
  289                                         Objec t nameObj,  Object ty peObj,
  290                                         Objec t staticAr guments,
  291                                         Objec t[] append ixResult)  {
  292           Me thodHandle  bootstrap Method = ( MethodHand le)bootstr apMethodOb j;
  293           Cl ass<?> cal ler = (Cla ss<?>)call erObj;
  294           St ring name  = nameObj. toString() .intern();
  295           Me thodType t ype = (Met hodType)ty peObj;
  296           if  (!TRACE_M ETHOD_LINK AGE)
  297                return l inkCallSit eImpl(call er, bootst rapMethod,  name, typ e,
  298                                          stat icArgument s, appendi xResult);
  299           re turn linkC allSiteTra cing(calle r, bootstr apMethod,  name, type ,
  300                                         stati cArguments , appendix Result);
  301       }
  302       static  MemberNam e linkCall SiteImpl(C lass<?> ca ller,
  303                                             M ethodHandl e bootstra pMethod,
  304                                             S tring name , MethodTy pe type,
  305                                             O bject stat icArgument s,
  306                                             O bject[] ap pendixResu lt) {
  307           Ca llSite cal lSite = Ca llSite.mak eSite(boot strapMetho d,
  308                                                     name ,
  309                                                     type ,
  310                                                     stat icArgument s,
  311                                                     call er);
  312           if  (callSite  instanceo f Constant CallSite)  {
  313                appendix Result[0]  = callSite .dynamicIn voker();
  314                return I nvokers.li nkToTarget Method(typ e);
  315           }  else {
  316                appendix Result[0]  = callSite ;
  317                return I nvokers.li nkToCallSi teMethod(t ype);
  318           }
  319       }
  320       // Tra cing logic :
  321       static  MemberNam e linkCall SiteTracin g(Class<?>  caller,
  322                                                 MethodHa ndle boots trapMethod ,
  323                                                 String n ame, Metho dType type ,
  324                                                 Object s taticArgum ents,
  325                                                 Object[]  appendixR esult) {
  326           Ob ject bsmRe ference =  bootstrapM ethod.inte rnalMember Name();
  327           if  (bsmRefer ence == nu ll)  bsmRe ference =  bootstrapM ethod;
  328           Ob ject stati cArglist =  (staticAr guments in stanceof O bject[] ?
  329                                      java.uti l.Arrays.a sList((Obj ect[]) sta ticArgumen ts) :
  330                                      staticAr guments);
  331           Sy stem.out.p rintln("li nkCallSite  "+caller. getName()+ " "+
  332                                bsm Reference+ " "+
  333                                nam e+type+"/" +staticArg list);
  334           tr y {
  335                MemberNa me res = l inkCallSit eImpl(call er, bootst rapMethod,  name, typ e,
  336                                                     stat icArgument s, appendi xResult);
  337                System.o ut.println ("linkCall Site => "+ res+" + "+ appendixRe sult[0]);
  338                return r es;
  339           }  catch (Thr owable ex)  {
  340                System.o ut.println ("linkCall Site => th row "+ex);
  341                throw ex ;
  342           }
  343       }
  344  
  345       /**
  346        * The  JVM wants  a pointer  to a Meth odType.  O blige it b y finding  or creatin g one.
  347        */
  348       static  MethodTyp e findMeth odHandleTy pe(Class<? > rtype, C lass<?>[]  ptypes) {
  349           re turn Metho dType.make Impl(rtype , ptypes,  true);
  350       }
  351  
  352       /**
  353        * The  JVM wants  to link a  call site  that requ ires a dyn amic type  check.
  354        * Nam e is a typ e-checking  invoker,  invokeExac t or invok e.
  355        * Ret urn a JVM  method (Me mberName)  to handle  the invoki ng.
  356        * The  method as sumes the  following  arguments  on the sta ck:
  357        * 0:  the method  handle be ing invoke d
  358        * 1-N : the argu ments to t he method  handle inv ocation
  359        * N+1 : an optio nal, impli citly adde d argument  (typicall y the give n MethodTy pe)
  360        * <p>
  361        * The  nominal m ethod at s uch a call  site is a n instance  of
  362        * a s ignature-p olymorphic  method (s ee @Polymo rphicSigna ture).
  363        * Suc h method i nstances a re user-vi sible enti ties which  are
  364        * "sp lit" from  the generi c placehol der method  in {@code  MethodHan dle}.
  365        * (No te that th e placehol der method  is not id entical wi th any of
  366        * its  instances .  If invo ked reflec tively, is  guarantee d to throw  an
  367        * {@c ode Unsupp ortedOpera tionExcept ion}.)
  368        * If  the signat ure-polymo rphic meth od instanc e is ever  reified,
  369        * it  appears as  a "copy"  of the ori ginal plac eholder
  370        * (a  native fin al member  of {@code  MethodHand le}) excep t
  371        * tha t its type  descripto r has shap e required  by the in stance,
  372        * and  the metho d instance  is <em>no t</em> var args.
  373        * The  method in stance is  also marke d syntheti c, since t he
  374        * met hod (by de finition)  does not a ppear in J ava source  code.
  375        * <p>
  376        * The  JVM is al lowed to r eify this  method as  instance m etadata.
  377        * For  example,  {@code inv okeBasic}  is always  reified.
  378        * But  the JVM m ay instead  call {@co de linkMet hod}.
  379        * If  the result  is an * o rdered pai r of a {@c ode (metho d, appendi x)},
  380        * the  method ge ts all the  arguments  (0..N inc lusive)
  381        * plu s the appe ndix (N+1) , and uses  the appen dix to com plete the  call.
  382        * In  this way,  one reusab le method  (called a  "linker me thod")
  383        * can  perform t he functio n of any n umber of p olymorphic  instance
  384        * met hods.
  385        * <p>
  386        * Lin ker method s are allo wed to be  weakly typ ed, with a ny or
  387        * all  reference s rewritte n to {@cod e Object}  and any pr imitives
  388        * (ex cept {@cod e long}/{@ code float }/{@code d ouble})
  389        * rew ritten to  {@code int }.
  390        * A l inker meth od is trus ted to ret urn a stro ngly typed  result,
  391        * acc ording to  the specif ic method  type descr iptor of t he
  392        * sig nature-pol ymorphic i nstance it  is emulat ing.
  393        * Thi s can invo lve (as ne cessary) a  dynamic c heck using
  394        * dat a extracte d from the  appendix  argument.
  395        * <p>
  396        * The  JVM does  not inspec t the appe ndix, othe r than to  pass
  397        * it  verbatim t o the link er method  at every c all.
  398        * Thi s means th at the JDK  runtime h as wide la titude
  399        * for  choosing  the shape  of each li nker metho d and its
  400        * cor responding  appendix.
  401        * Lin ker method s should b e generate d from {@c ode Lambda Form}s
  402        * so  that they  do not bec ome visibl e on stack  traces.
  403        * <p>
  404        * The  {@code li nkMethod}  call is fr ee to omit  the appen dix
  405        * (re turning nu ll) and in stead emul ate the re quired fun ction
  406        * com pletely in  the linke r method.
  407        * As  a corner c ase, if N= =255, no a ppendix is  possible.
  408        * In  this case,  the metho d returned  must be c ustom-gene rated to
  409        * to  perform an y needed t ype checki ng.
  410        * <p>
  411        * If  the JVM do es not rei fy a metho d at a cal l site, bu t instead
  412        * cal ls {@code  linkMethod }, the cor responding  call repr esented
  413        * in  the byteco des may me ntion a va lid method  which is  not
  414        * rep resentable  with a {@ code Membe rName}.
  415        * The refore, us e cases fo r {@code l inkMethod}  tend to c orrespond  to
  416        * spe cial cases  in reflec tive code  such as {@ code findV irtual}
  417        * or  {@code rev ealDirect} .
  418        */
  419       static  MemberNam e linkMeth od(Class<? > callerCl ass, int r efKind,
  420                                       Class<? > defc, St ring name,  Object ty pe,
  421                                       Object[ ] appendix Result) {
  422           if  (!TRACE_M ETHOD_LINK AGE)
  423                return l inkMethodI mpl(caller Class, ref Kind, defc , name, ty pe, append ixResult);
  424           re turn linkM ethodTraci ng(callerC lass, refK ind, defc,  name, typ e, appendi xResult);
  425       }
  426       static  MemberNam e linkMeth odImpl(Cla ss<?> call erClass, i nt refKind ,
  427                                           Cla ss<?> defc , String n ame, Objec t type,
  428                                           Obj ect[] appe ndixResult ) {
  429           tr y {
  430                if (defc  == Method Handle.cla ss && refK ind == REF _invokeVir tual) {
  431                    retu rn Invoker s.methodHa ndleInvoke LinkerMeth od(name, f ixMethodTy pe(callerC lass, type ), appendi xResult);
  432                }
  433           }  catch (Thr owable ex)  {
  434                if (ex i nstanceof  LinkageErr or)
  435                    thro w (Linkage Error) ex;
  436                else
  437                    thro w new Link ageError(e x.getMessa ge(), ex);
  438           }
  439           th row new Li nkageError ("no such  method "+d efc.getNam e()+"."+na me+type);
  440       }
  441       privat e static M ethodType  fixMethodT ype(Class< ?> callerC lass, Obje ct type) {
  442           if  (type ins tanceof Me thodType)
  443                return ( MethodType ) type;
  444           el se
  445                return M ethodType. fromMethod Descriptor String((St ring)type,  callerCla ss.getClas sLoader()) ;
  446       }
  447       // Tra cing logic :
  448       static  MemberNam e linkMeth odTracing( Class<?> c allerClass , int refK ind,
  449                                               Class<?> d efc, Strin g name, Ob ject type,
  450                                               Object[] a ppendixRes ult) {
  451           Sy stem.out.p rintln("li nkMethod " +defc.getN ame()+"."+
  452                                nam e+type+"/" +Integer.t oHexString (refKind)) ;
  453           tr y {
  454                MemberNa me res = l inkMethodI mpl(caller Class, ref Kind, defc , name, ty pe, append ixResult);
  455                System.o ut.println ("linkMeth od => "+re s+" + "+ap pendixResu lt[0]);
  456                return r es;
  457           }  catch (Thr owable ex)  {
  458                System.o ut.println ("linkMeth od => thro w "+ex);
  459                throw ex ;
  460           }
  461       }
  462  
  463  
  464       /**
  465        * The  JVM is re solving a  CONSTANT_M ethodHandl e CP entry .  And it  wants our  help.
  466        * It  will make  an up-call  to this m ethod.  (D o not chan ge the nam e or signa ture.)
  467        * The  type argu ment is a  Class for  field requ ests and a  MethodTyp e for non- fields.
  468        * <p>
  469        * Rec ent versio ns of the  JVM may al so pass a  resolved M emberName  for the ty pe.
  470        * In  that case,  the name  is ignored  and may b e null.
  471        */
  472       static  MethodHan dle linkMe thodHandle Constant(C lass<?> ca llerClass,  int refKi nd,
  473                                                        C lass<?> de fc, String  name, Obj ect type)  {
  474           tr y {
  475                Lookup l ookup = IM PL_LOOKUP. in(callerC lass);
  476                assert(r efKindIsVa lid(refKin d));
  477                return l ookup.link MethodHand leConstant ((byte) re fKind, def c, name, t ype);
  478           }  catch (Ill egalAccess Exception  ex) {
  479                Throwabl e cause =  ex.getCaus e();
  480                if (caus e instance of Abstrac tMethodErr or) {
  481                    thro w (Abstrac tMethodErr or) cause;
  482                } else {
  483                    Erro r err = ne w IllegalA ccessError (ex.getMes sage());
  484                    thro w initCaus eFrom(err,  ex);
  485                }
  486           }  catch (NoS uchMethodE xception e x) {
  487                Error er r = new No SuchMethod Error(ex.g etMessage( ));
  488                throw in itCauseFro m(err, ex) ;
  489           }  catch (NoS uchFieldEx ception ex ) {
  490                Error er r = new No SuchFieldE rror(ex.ge tMessage() );
  491                throw in itCauseFro m(err, ex) ;
  492           }  catch (Ref lectiveOpe rationExce ption ex)  {
  493                Error er r = new In compatible ClassChang eError();
  494                throw in itCauseFro m(err, ex) ;
  495           }
  496       }
  497  
  498       /**
  499        * Use  best poss ible cause  for err.i nitCause() , substitu ting the
  500        * cau se for err  itself if  the cause  has the s ame (or be tter) type .
  501        */
  502       static  private E rror initC auseFrom(E rror err,  Exception  ex) {
  503           Th rowable th  = ex.getC ause();
  504           if  (err.getC lass().isI nstance(th ))
  505               return (E rror) th;
  506           er r.initCaus e(th == nu ll ? ex :  th);
  507           re turn err;
  508       }
  509  
  510       /**
  511        * Is  this metho d a caller -sensitive  method?
  512        * I.e ., does it  call Refl ection.get CallerClas s or a sim iler metho d
  513        * to  ask about  the identi ty of its  caller?
  514        */
  515       static  boolean i sCallerSen sitive(Mem berName me m) {
  516           if  (!mem.isI nvocable() )  return  false;  //  fields ar e not call er sensiti ve
  517  
  518           re turn mem.i sCallerSen sitive() | | canBeCal ledVirtual (mem);
  519       }
  520  
  521       static  boolean c anBeCalled Virtual(Me mberName m em) {
  522           as sert(mem.i sInvocable ());
  523           Cl ass<?> def c = mem.ge tDeclaring Class();
  524           sw itch (mem. getName())  {
  525           ca se "checkM emberAcces s":
  526                return c anBeCalled Virtual(me m, java.la ng.Securit yManager.c lass);
  527           ca se "getCon textClassL oader":
  528                return c anBeCalled Virtual(me m, java.la ng.Thread. class);
  529           }
  530           re turn false ;
  531       }
  532  
  533       static  boolean c anBeCalled Virtual(Me mberName s ymbolicRef , Class<?>  definingC lass) {
  534           Cl ass<?> sym bolicRefCl ass = symb olicRef.ge tDeclaring Class();
  535           if  (symbolic RefClass = = defining Class)  re turn true;
  536           if  (symbolic Ref.isStat ic() || sy mbolicRef. isPrivate( ))  return  false;
  537           re turn (defi ningClass. isAssignab leFrom(sym bolicRefCl ass) ||  / / Msym ove rrides Mde f
  538                    symb olicRefCla ss.isInter face());                       / / Mdef imp lements Ms ym
  539       }
  540   }