301. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:28 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.

301.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\sun\tools\attach HotSpotVirtualMachine.java Mon Jan 22 14:46:56 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\sun\tools\attach HotSpotVirtualMachine.java Wed Sep 12 18:00:38 2018 UTC

301.2 Comparison summary

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

301.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

301.4 Active regular expressions

No regular expressions were active.

301.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 200 5, 2014, 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 su n.tools.at tach;
  27  
  28   import com .sun.tools .attach.Vi rtualMachi ne;
  29   import com .sun.tools .attach.Ag entLoadExc eption;
  30   import com .sun.tools .attach.Ag entInitial izationExc eption;
  31   import com .sun.tools .attach.sp i.AttachPr ovider;
  32  
  33   import jav a.io.Input Stream;
  34   import jav a.io.IOExc eption;
  35   import jav a.util.Pro perties;
  36   import jav a.util.str eam.Collec tors;
  37  
  38   /*
  39    * The Hot Spot imple mentation  of com.sun .tools.att ach.Virtua lMachine.
  40    */
  41  
  42   public abs tract clas s HotSpotV irtualMach ine extend s VirtualM achine {
  43  
  44       HotSpo tVirtualMa chine(Atta chProvider  provider,  String id ) {
  45           su per(provid er, id);
  46       }
  47  
  48       /*
  49        * Loa d agent li brary
  50        * If  isAbsolute  is true t hen the ag ent librar y is the a bsolute pa th
  51        * to  the librar y and thus  will not  be expande d in the t arget VM.
  52        * if  isAbsolute  is false  then the a gent libra ry is just  a library
  53        * nam e and it w ill be exp ended in t he target  VM.
  54        */
  55       privat e void loa dAgentLibr ary(String  agentLibr ary, boole an isAbsol ute, Strin g options)
  56           th rows Agent LoadExcept ion, Agent Initializa tionExcept ion, IOExc eption
  57       {
  58           In putStream  in = execu te("load",
  59                                       agentLi brary,
  60                                       isAbsol ute ? "tru e" : "fals e",
  61                                       options );
  62           tr y {
  63                int resu lt = readI nt(in);
  64                if (resu lt != 0) {
  65                    thro w new Agen tInitializ ationExcep tion("Agen t_OnAttach  failed",  result);
  66                }
  67           }  finally {
  68                in.close ();
  69  
  70           }
  71       }
  72  
  73       /*
  74        * Loa d agent li brary - li brary name  will be e xpanded in  target VM
  75        */
  76       public  void load AgentLibra ry(String  agentLibra ry, String  options)
  77           th rows Agent LoadExcept ion, Agent Initializa tionExcept ion, IOExc eption
  78       {
  79           lo adAgentLib rary(agent Library, f alse, opti ons);
  80       }
  81  
  82       /*
  83        * Loa d agent -  absolute p ath of lib rary provi ded to tar get VM
  84        */
  85       public  void load AgentPath( String age ntLibrary,  String op tions)
  86           th rows Agent LoadExcept ion, Agent Initializa tionExcept ion, IOExc eption
  87       {
  88           lo adAgentLib rary(agent Library, t rue, optio ns);
  89       }
  90  
  91       /*
  92        * Loa d JPLIS ag ent which  will load  the agent  JAR file a nd invoke
  93        * the  agentmain  method.
  94        */
  95       public  void load Agent(Stri ng agent,  String opt ions)
  96           th rows Agent LoadExcept ion, Agent Initializa tionExcept ion, IOExc eption
  97       {
  98           St ring args  = agent;
  99           if  (options  != null) {
  100                args = a rgs + "="  + options;
  101           }
  102           tr y {
  103                loadAgen tLibrary(" instrument ", args);
  104           }  catch (Age ntLoadExce ption x) {
  105                throw ne w Internal Error("ins trument li brary is m issing in  target VM" , x);
  106           }  catch (Age ntInitiali zationExce ption x) {
  107                /*
  108                 * Trans late inter esting err ors into t he right e xception a nd
  109                 * messa ge (FIXME:  create a  better int erface to  the instru ment
  110                 * imple mentation  so this is n't necess ary)
  111                 */
  112                int rc =  x.returnV alue();
  113                switch ( rc) {
  114                    case  JNI_ENOME M:
  115                         throw new  AgentLoadE xception(" Insuffient  memory");
  116                    case  ATTACH_ER ROR_BADJAR :
  117                         throw new  AgentLoadE xception(" Agent JAR  not found  or no Agen t-Class at tribute");
  118                    case  ATTACH_ER ROR_NOTONC P:
  119                         throw new  AgentLoadE xception(" Unable to  add JAR fi le to syst em class p ath");
  120                    case  ATTACH_ER ROR_STARTF AIL:
  121                         throw new  AgentIniti alizationE xception(" Agent JAR  loaded but  agent fai led to ini tialize");
  122                    defa ult :
  123                         throw new  AgentLoadE xception(" Failed to  load agent  - unknown  reason: "  + rc);
  124                }
  125           }
  126       }
  127  
  128       /*
  129        * The  possible  errors ret urned by J PLIS's age ntmain
  130        */
  131       privat e static f inal int J NI_ENOMEM                   = -4 ;
  132       privat e static f inal int A TTACH_ERRO R_BADJAR         = 10 0;
  133       privat e static f inal int A TTACH_ERRO R_NOTONCP        = 10 1;
  134       privat e static f inal int A TTACH_ERRO R_STARTFAI L     = 10 2;
  135  
  136  
  137       /*
  138        * Sen d "propert ies" comma nd to targ et VM
  139        */
  140       public  Propertie s getSyste mPropertie s() throws  IOExcepti on {
  141           In putStream  in = null;
  142           Pr operties p rops = new  Propertie s();
  143           tr y {
  144                in = exe cuteComman d("propert ies");
  145                props.lo ad(in);
  146           }  finally {
  147                if (in ! = null) in .close();
  148           }
  149           re turn props ;
  150       }
  151  
  152       public  Propertie s getAgent Properties () throws  IOExceptio n {
  153           In putStream  in = null;
  154           Pr operties p rops = new  Propertie s();
  155           tr y {
  156                in = exe cuteComman d("agentPr operties") ;
  157                props.lo ad(in);
  158           }  finally {
  159                if (in ! = null) in .close();
  160           }
  161           re turn props ;
  162       }
  163  
  164       privat e static f inal Strin g MANAGMEN T_PREFIX =  "com.sun. management .";
  165  
  166       privat e static b oolean che ckedKeyNam e(Object k ey) {
  167           if  (!(key in stanceof S tring)) {
  168                throw ne w IllegalA rgumentExc eption("In valid opti on (not a  String): " +key);
  169           }
  170           if  (!((Strin g)key).sta rtsWith(MA NAGMENT_PR EFIX)) {
  171                throw ne w IllegalA rgumentExc eption("In valid opti on: "+key) ;
  172           }
  173           re turn true;
  174       }
  175  
  176       privat e static S tring stri pKeyName(O bject key)  {
  177           re turn ((Str ing)key).s ubstring(M ANAGMENT_P REFIX.leng th());
  178       }
  179  
  180       @Overr ide
  181       public  void star tManagemen tAgent(Pro perties ag entPropert ies) throw s IOExcept ion {
  182           if  (agentPro perties ==  null) {
  183                throw ne w NullPoin terExcepti on("agentP roperties  cannot be  null");
  184           }
  185           //  Convert t he argumen ts into ar guments su itable for  the Diagn ostic Comm and:
  186             // "Manage mentAgent. start jmxr emote. PORT         jmxremote. authentica te=false"
  187           St ring args  = agentPro perties.en trySet().s tream()
  188                .filter( entry -> c heckedKeyN ame(entry. getKey()))
  189                .map(ent ry -> stri pKeyName(e ntry.getKe y()) + "="  + escape( entry.getV alue()))
  190                .collect (Collector s.joining( " "));
  191           ex ecuteJCmd( "Managemen tAgent.sta rt " + arg s);
  192       }
  193  
  194       privat e String e scape(Obje ct arg) {
  195           St ring value  = arg.toS tring();
  196           if  (value.co ntains(" " )) {
  197                return " '" + value  + "'";
  198           }
  199           re turn value ;
  200       }
  201  
  202       @Overr ide
  203       public  String st artLocalMa nagementAg ent() thro ws IOExcep tion {
  204           ex ecuteJCmd( "Managemen tAgent.sta rt_local") ;
  205           re turn getAg entPropert ies().getP roperty("c om.sun.man agement.jm xremote.lo calConnect orAddress" );
  206       }
  207  
  208       // ---  HotSpot s pecific me thods ---
  209  
  210       // sam e as SIGQU IT
  211       public  void loca lDataDump( ) throws I OException  {
  212           ex ecuteComma nd("datadu mp").close ();
  213       }
  214  
  215       // Rem ote ctrl-b reak. The  output of  the ctrl-b reak actio ns can
  216       // be  read from  the input  stream.
  217       public  InputStre am remoteD ataDump(Ob ject ... a rgs) throw s IOExcept ion {
  218           re turn execu teCommand( "threaddum p", args);
  219       }
  220  
  221       // Rem ote heap d ump. The o utput (err or message ) can be r ead from t he
  222       // ret urned inpu t stream.
  223       public  InputStre am dumpHea p(Object . .. args) t hrows IOEx ception {
  224           re turn execu teCommand( "dumpheap" , args);
  225       }
  226  
  227       // Hea p histogra m (heap in spection i n HotSpot)
  228       public  InputStre am heapHis to(Object  ... args)  throws IOE xception {
  229           re turn execu teCommand( "inspecthe ap", args) ;
  230       }
  231  
  232       // set  JVM comma nd line fl ag
  233       public  InputStre am setFlag (String na me, String  value) th rows IOExc eption {
  234           re turn execu teCommand( "setflag",  name, val ue);
  235       }
  236  
  237       // pri nt command  line flag
  238       public  InputStre am printFl ag(String  name) thro ws IOExcep tion {
  239           re turn execu teCommand( "printflag ", name);
  240       }
  241  
  242       public  InputStre am execute JCmd(Strin g command)  throws IO Exception  {
  243           re turn execu teCommand( "jcmd", co mmand);
  244       }
  245  
  246       // --  Supporting  methods
  247  
  248  
  249       /*
  250        * Exe cute the g iven comma nd in the  target VM  - specific  platform
  251        * imp lementatio n must imp lement thi s.
  252        */
  253       abstra ct InputSt ream execu te(String  cmd, Objec t ... args )
  254           th rows Agent LoadExcept ion, IOExc eption;
  255  
  256       /*
  257        * Con venience m ethod for  simple com mands
  258        */
  259       privat e InputStr eam execut eCommand(S tring cmd,  Object .. . args) th rows IOExc eption {
  260           tr y {
  261                return e xecute(cmd , args);
  262           }  catch (Age ntLoadExce ption x) {
  263                throw ne w Internal Error("Sho uld not ge t here", x );
  264           }
  265       }
  266  
  267  
  268       /*
  269        * Uti lity metho d to read  an 'int' f rom the in put stream . Ideally
  270        * we  should be  using java .util.Scan ner here b ut this im plementati on
  271        * gua rantees no t to read  ahead.
  272        */
  273       int re adInt(Inpu tStream in ) throws I OException  {
  274           St ringBuilde r sb = new  StringBui lder();
  275  
  276           //  read to \ n or EOF
  277           in t n;
  278           by te buf[] =  new byte[ 1];
  279           do  {
  280                n = in.r ead(buf, 0 , 1);
  281                if (n >  0) {
  282                    char  c = (char )buf[0];
  283                    if ( c == '\n')  {
  284                         break;                    // EOL  found
  285                    } el se {
  286                         sb.append( c);
  287                    }
  288                }
  289           }  while (n >  0);
  290  
  291           if  (sb.lengt h() == 0)  {
  292                throw ne w IOExcept ion("Prema ture EOF") ;
  293           }
  294  
  295           in t value;
  296           tr y {
  297                value =  Integer.pa rseInt(sb. toString() );
  298           }  catch (Num berFormatE xception x ) {
  299                throw ne w IOExcept ion("Non-n umeric val ue found -  int expec ted");
  300           }
  301           re turn value ;
  302       }
  303  
  304       /*
  305        * Uti lity metho d to read  data into  a String.
  306        */
  307       String  readError Message(In putStream  sis) throw s IOExcept ion {
  308           by te b[] = n ew byte[10 24];
  309           in t n;
  310           St ringBuffer  message =  new Strin gBuffer();
  311           wh ile ((n =  sis.read(b )) != -1)  {
  312                message. append(new  String(b,  0, n, "UT F-8"));
  313           }
  314           re turn messa ge.toStrin g();
  315       }
  316  
  317  
  318       // --  attach tim eout suppo rt
  319  
  320       privat e static l ong defaul tAttachTim eout = 500 0;
  321       privat e volatile  long atta chTimeout;
  322  
  323       /*
  324        * Ret urn attach  timeout b ased on th e value of  the sun.t ools.attac h.attachTi meout
  325        * pro perty, or  the defaul t timeout  if the pro perty is n ot set to  a positive
  326        * val ue.
  327        */
  328       long a ttachTimeo ut() {
  329           if  (attachTi meout == 0 ) {
  330                synchron ized(this)  {
  331                    if ( attachTime out == 0)  {
  332                         try {
  333                             String  s =
  334                                 Sy stem.getPr operty("su n.tools.at tach.attac hTimeout") ;
  335                             attach Timeout =  Long.parse Long(s);
  336                         } catch (S ecurityExc eption se)  {
  337                         } catch (N umberForma tException  ne) {
  338                         }
  339                         if (attach Timeout <=  0) {
  340                            attachT imeout = d efaultAtta chTimeout;
  341                         }
  342                    }
  343                }
  344           }
  345           re turn attac hTimeout;
  346       }
  347   }