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

162.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 System.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 System.java Wed Sep 12 17:08:20 2018 UTC

162.2 Comparison summary

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

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

162.4 Active regular expressions

No regular expressions were active.

162.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 4, 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   package ja va.lang;
  26  
  27   import jav a.io.*;
  28   import jav a.lang.ref lect.Execu table;
  29   import jav a.lang.ann otation.An notation;
  30   import jav a.security .AccessCon trolContex t;
  31   import jav a.util.Pro perties;
  32   import jav a.util.Pro pertyPermi ssion;
  33   import jav a.util.Str ingTokeniz er;
  34   import jav a.util.Map ;
  35   import jav a.security .AccessCon troller;
  36   import jav a.security .Privilege dAction;
  37   import jav a.security .AllPermis sion;
  38   import jav a.nio.chan nels.Chann el;
  39   import jav a.nio.chan nels.spi.S electorPro vider;
  40   import sun .nio.ch.In terruptibl e;
  41   import sun .reflect.C allerSensi tive;
  42   import sun .reflect.R eflection;
  43   import sun .security. util.Secur ityConstan ts;
  44   import sun .reflect.a nnotation. Annotation Type;
  45  
  46   /**
  47    * The <co de>System< /code> cla ss contain s several  useful cla ss fields
  48    * and met hods. It c annot be i nstantiate d.
  49    *
  50    * <p>Amon g the faci lities pro vided by t he <code>S ystem</cod e> class
  51    * are sta ndard inpu t, standar d output,  and error  output str eams;
  52    * access  to externa lly define d properti es and env ironment
  53    * variabl es; a mean s of loadi ng files a nd librari es; and a  utility
  54    * method  for quickl y copying  a portion  of an arra y.
  55    *
  56    * @author   unascrib ed
  57    * @since    JDK1.0
  58    */
  59   public fin al class S ystem {
  60  
  61       /* reg ister the  natives vi a the stat ic initial izer.
  62        *
  63        * VM  will invok e the init ializeSyst emClass me thod to co mplete
  64        * the  initializ ation for  this class  separated  from clin it.
  65        * Not e that to  use proper ties set b y the VM,  see the co nstraints
  66        * des cribed in  the initia lizeSystem Class meth od.
  67        */
  68       privat e static n ative void  registerN atives();
  69       static  {
  70           re gisterNati ves();
  71       }
  72  
  73       /** Do n't let an yone insta ntiate thi s class */
  74       privat e System()  {
  75       }
  76  
  77       /**
  78        * The  "standard " input st ream. This  stream is  already
  79        * ope n and read y to suppl y input da ta. Typica lly this s tream
  80        * cor responds t o keyboard  input or  another in put source  specified  by
  81        * the  host envi ronment or  user.
  82        */
  83       public  final sta tic InputS tream in =  null;
  84  
  85       /**
  86        * The  "standard " output s tream. Thi s stream i s already
  87        * ope n and read y to accep t output d ata. Typic ally this  stream
  88        * cor responds t o display  output or  another ou tput desti nation
  89        * spe cified by  the host e nvironment  or user.
  90        * <p>
  91        * For  simple st and-alone  Java appli cations, a  typical w ay to writ e
  92        * a l ine of out put data i s:
  93        * <bl ockquote>< pre>
  94        *      System.ou t.println( data)
  95        * </p re></block quote>
  96        * <p>
  97        * See  the <code >println</ code> meth ods in cla ss <code>P rintStream </code>.
  98        *
  99        * @se e     java .io.PrintS tream#prin tln()
  100        * @se e     java .io.PrintS tream#prin tln(boolea n)
  101        * @se e     java .io.PrintS tream#prin tln(char)
  102        * @se e     java .io.PrintS tream#prin tln(char[] )
  103        * @se e     java .io.PrintS tream#prin tln(double )
  104        * @se e     java .io.PrintS tream#prin tln(float)
  105        * @se e     java .io.PrintS tream#prin tln(int)
  106        * @se e     java .io.PrintS tream#prin tln(long)
  107        * @se e     java .io.PrintS tream#prin tln(java.l ang.Object )
  108        * @se e     java .io.PrintS tream#prin tln(java.l ang.String )
  109        */
  110       public  final sta tic PrintS tream out  = null;
  111  
  112       /**
  113        * The  "standard " error ou tput strea m. This st ream is al ready
  114        * ope n and read y to accep t output d ata.
  115        * <p>
  116        * Typ ically thi s stream c orresponds  to displa y output o r another
  117        * out put destin ation spec ified by t he host en vironment  or user. B y
  118        * con vention, t his output  stream is  used to d isplay err or message s
  119        * or  other info rmation th at should  come to th e immediat e attentio n
  120        * of  a user eve n if the p rincipal o utput stre am, the va lue of the
  121        * var iable <cod e>out</cod e>, has be en redirec ted to a f ile or oth er
  122        * des tination t hat is typ ically not  continuou sly monito red.
  123        */
  124       public  final sta tic PrintS tream err  = null;
  125  
  126       /* The  security  manager fo r the syst em.
  127        */
  128       privat e static v olatile Se curityMana ger securi ty = null;
  129  
  130       /**
  131        * Rea ssigns the  "standard " input st ream.
  132        *
  133        * <p> First, if  there is a  security  manager, i ts <code>c heckPermis sion</code >
  134        * met hod is cal led with a  <code>Run timePermis sion("setI O")</code>  permissio n
  135        *  to  see if it 's ok to r eassign th e "standar d" input s tream.
  136        * <p>
  137        *
  138        * @pa ram in the  new stand ard input  stream.
  139        *
  140        * @th rows Secur ityExcepti on
  141        *         if a s ecurity ma nager exis ts and its
  142        *         <code> checkPermi ssion</cod e> method  doesn't al low
  143        *         reassi gning of t he standar d input st ream.
  144        *
  145        * @se e Security Manager#ch eckPermiss ion
  146        * @se e java.lan g.RuntimeP ermission
  147        *
  148        * @si nce   JDK1 .1
  149        */
  150       public  static vo id setIn(I nputStream  in) {
  151           ch eckIO();
  152           se tIn0(in);
  153       }
  154  
  155       /**
  156        * Rea ssigns the  "standard " output s tream.
  157        *
  158        * <p> First, if  there is a  security  manager, i ts <code>c heckPermis sion</code >
  159        * met hod is cal led with a  <code>Run timePermis sion("setI O")</code>  permissio n
  160        *  to  see if it 's ok to r eassign th e "standar d" output  stream.
  161        *
  162        * @pa ram out th e new stan dard outpu t stream
  163        *
  164        * @th rows Secur ityExcepti on
  165        *         if a s ecurity ma nager exis ts and its
  166        *         <code> checkPermi ssion</cod e> method  doesn't al low
  167        *         reassi gning of t he standar d output s tream.
  168        *
  169        * @se e Security Manager#ch eckPermiss ion
  170        * @se e java.lan g.RuntimeP ermission
  171        *
  172        * @si nce   JDK1 .1
  173        */
  174       public  static vo id setOut( PrintStrea m out) {
  175           ch eckIO();
  176           se tOut0(out) ;
  177       }
  178  
  179       /**
  180        * Rea ssigns the  "standard " error ou tput strea m.
  181        *
  182        * <p> First, if  there is a  security  manager, i ts <code>c heckPermis sion</code >
  183        * met hod is cal led with a  <code>Run timePermis sion("setI O")</code>  permissio n
  184        *  to  see if it 's ok to r eassign th e "standar d" error o utput stre am.
  185        *
  186        * @pa ram err th e new stan dard error  output st ream.
  187        *
  188        * @th rows Secur ityExcepti on
  189        *         if a s ecurity ma nager exis ts and its
  190        *         <code> checkPermi ssion</cod e> method  doesn't al low
  191        *         reassi gning of t he standar d error ou tput strea m.
  192        *
  193        * @se e Security Manager#ch eckPermiss ion
  194        * @se e java.lan g.RuntimeP ermission
  195        *
  196        * @si nce   JDK1 .1
  197        */
  198       public  static vo id setErr( PrintStrea m err) {
  199           ch eckIO();
  200           se tErr0(err) ;
  201       }
  202  
  203       privat e static v olatile Co nsole cons  = null;
  204       /**
  205        * Ret urns the u nique {@li nk java.io .Console C onsole} ob ject assoc iated
  206        * wit h the curr ent Java v irtual mac hine, if a ny.
  207        *
  208        * @re turn  The  system con sole, if a ny, otherw ise <tt>nu ll</tt>.
  209        *
  210        * @si nce   1.6
  211        */
  212        publi c static C onsole con sole() {
  213            i f (cons ==  null) {
  214                 synchro nized (Sys tem.class)  {
  215                     con s = sun.mi sc.SharedS ecrets.get JavaIOAcce ss().conso le();
  216                 }
  217            }
  218            r eturn cons ;
  219        }
  220  
  221       /**
  222        * Ret urns the c hannel inh erited fro m the enti ty that cr eated this
  223        * Jav a virtual  machine.
  224        *
  225        * <p>  This meth od returns  the chann el obtaine d by invok ing the
  226        * {@l ink java.n io.channel s.spi.Sele ctorProvid er#inherit edChannel
  227        * inh eritedChan nel} metho d of the s ystem-wide  default
  228        * {@l ink java.n io.channel s.spi.Sele ctorProvid er} object . </p>
  229        *
  230        * <p>  In additi on to the  network-or iented cha nnels desc ribed in
  231        * {@l ink java.n io.channel s.spi.Sele ctorProvid er#inherit edChannel
  232        * inh eritedChan nel}, this  method ma y return o ther kinds  of
  233        * cha nnels in t he future.
  234        *
  235        * @re turn  The  inherited  channel, i f any, oth erwise <tt >null</tt> .
  236        *
  237        * @th rows  IOEx ception
  238        *           If a n I/O erro r occurs
  239        *
  240        * @th rows  Secu rityExcept ion
  241        *           If a  security  manager is  present a nd it does  not
  242        *           perm it access  to the cha nnel.
  243        *
  244        * @si nce 1.5
  245        */
  246       public  static Ch annel inhe ritedChann el() throw s IOExcept ion {
  247           re turn Selec torProvide r.provider ().inherit edChannel( );
  248       }
  249  
  250       privat e static v oid checkI O() {
  251           Se curityMana ger sm = g etSecurity Manager();
  252           if  (sm != nu ll) {
  253                sm.check Permission (new Runti mePermissi on("setIO" ));
  254           }
  255       }
  256  
  257       privat e static n ative void  setIn0(In putStream  in);
  258       privat e static n ative void  setOut0(P rintStream  out);
  259       privat e static n ative void  setErr0(P rintStream  err);
  260  
  261       /**
  262        * Set s the Syst em securit y.
  263        *
  264        * <p>  If there  is a secur ity manage r already  installed,  this meth od first
  265        * cal ls the sec urity mana ger's <cod e>checkPer mission</c ode> metho d
  266        * wit h a <code> RuntimePer mission("s etSecurity Manager")< /code>
  267        * per mission to  ensure it 's ok to r eplace the  existing
  268        * sec urity mana ger.
  269        * Thi s may resu lt in thro wing a <co de>Securit yException </code>.
  270        *
  271        * <p>  Otherwise , the argu ment is es tablished  as the cur rent
  272        * sec urity mana ger. If th e argument  is <code> null</code > and no
  273        * sec urity mana ger has be en establi shed, then  no action  is taken  and
  274        * the  method si mply retur ns.
  275        *
  276        * @pa ram      s    the sec urity mana ger.
  277        * @ex ception  S ecurityExc eption  if  the secur ity manage r has alre ady
  278        *              b een set an d its <cod e>checkPer mission</c ode> metho d
  279        *              d oesn't all ow it to b e replaced .
  280        * @se e #getSecu rityManage r
  281        * @se e Security Manager#ch eckPermiss ion
  282        * @se e java.lan g.RuntimeP ermission
  283        */
  284       public  static
  285       void s etSecurity Manager(fi nal Securi tyManager  s) {
  286           tr y {
  287                s.checkP ackageAcce ss("java.l ang");
  288           }  catch (Exc eption e)  {
  289                // no-op
  290           }
  291           se tSecurityM anager0(s) ;
  292       }
  293  
  294       privat e static s ynchronize d
  295       void s etSecurity Manager0(f inal Secur ityManager  s) {
  296           Se curityMana ger sm = g etSecurity Manager();
  297           if  (sm != nu ll) {
  298                // ask t he current ly install ed securit y manager  if we
  299                // can r eplace it.
  300                sm.check Permission (new Runti mePermissi on
  301                                           ("s etSecurity Manager")) ;
  302           }
  303  
  304           if  ((s != nu ll) && (s. getClass() .getClassL oader() !=  null)) {
  305                // New s ecurity ma nager clas s is not o n bootstra p classpat h.
  306                // Cause  policy to  get initi alized bef ore we ins tall the n ew
  307                // secur ity manage r, in orde r to preve nt infinit e loops wh en
  308                // tryin g to initi alize the  policy (wh ich usuall y involves
  309                // acces sing some  security a nd/or syst em propert ies, which  in turn
  310                // calls  the insta lled secur ity manage r's checkP ermission  method
  311                // which  will loop  infinitel y if there  is a non- system cla ss
  312                // (in t his case:  the new se curity man ager class ) on the s tack).
  313                AccessCo ntroller.d oPrivilege d(new Priv ilegedActi on<Object> () {
  314                    publ ic Object  run() {
  315                         s.getClass ().getProt ectionDoma in().impli es
  316                             (Secur ityConstan ts.ALL_PER MISSION);
  317                         return nul l;
  318                    }
  319                });
  320           }
  321  
  322           se curity = s ;
  323       }
  324  
  325       /**
  326        * Get s the syst em securit y interfac e.
  327        *
  328        * @re turn  if a  security  manager ha s already  been estab lished for  the
  329        *           curr ent applic ation, the n that sec urity mana ger is ret urned;
  330        *           othe rwise, <co de>null</c ode> is re turned.
  331        * @se e     #set SecurityMa nager
  332        */
  333       public  static Se curityMana ger getSec urityManag er() {
  334           re turn secur ity;
  335       }
  336  
  337       /**
  338        * Ret urns the c urrent tim e in milli seconds.   Note that
  339        * whi le the uni t of time  of the ret urn value  is a milli second,
  340        * the  granulari ty of the  value depe nds on the  underlyin g
  341        * ope rating sys tem and ma y be large r.  For ex ample, man y
  342        * ope rating sys tems measu re time in  units of  tens of
  343        * mil liseconds.
  344        *
  345        * <p>  See the d escription  of the cl ass <code> Date</code > for
  346        * a d iscussion  of slight  discrepanc ies that m ay arise b etween
  347        * "co mputer tim e" and coo rdinated u niversal t ime (UTC).
  348        *
  349        * @re turn  the  difference , measured  in millis econds, be tween
  350        *           the  current ti me and mid night, Jan uary 1, 19 70 UTC.
  351        * @se e     java .util.Date
  352        */
  353       public  static na tive long  currentTim eMillis();
  354  
  355       /**
  356        * Ret urns the c urrent val ue of the  running Ja va Virtual  Machine's
  357        * hig h-resoluti on time so urce, in n anoseconds .
  358        *
  359        * <p> This metho d can only  be used t o measure  elapsed ti me and is
  360        * not  related t o any othe r notion o f system o r wall-clo ck time.
  361        * The  value ret urned repr esents nan oseconds s ince some  fixed but
  362        * arb itrary <i> origin</i>  time (per haps in th e future,  so values
  363        * may  be negati ve).  The  same origi n is used  by all inv ocations o f
  364        * thi s method i n an insta nce of a J ava virtua l machine;  other
  365        * vir tual machi ne instanc es are lik ely to use  a differe nt origin.
  366        *
  367        * <p> This metho d provides  nanosecon d precisio n, but not  necessari ly
  368        * nan osecond re solution ( that is, h ow frequen tly the va lue change s)
  369        * - n o guarante es are mad e except t hat the re solution i s at least  as
  370        * goo d as that  of {@link  #currentTi meMillis() }.
  371        *
  372        * <p> Difference s in succe ssive call s that spa n greater  than
  373        * app roximately  292 years  (2<sup>63 </sup> nan oseconds)  will not
  374        * cor rectly com pute elaps ed time du e to numer ical overf low.
  375        *
  376        * <p> The values  returned  by this me thod becom e meaningf ul only wh en
  377        * the  differenc e between  two such v alues, obt ained with in the sam e
  378        * ins tance of a  Java virt ual machin e, is comp uted.
  379        *
  380        * <p>  For examp le, to mea sure how l ong some c ode takes  to execute :
  381        *  <p re> {@code
  382        * lon g startTim e = System .nanoTime( );
  383        * //  ... the co de being m easured .. .
  384        * lon g estimate dTime = Sy stem.nanoT ime() - st artTime;}< /pre>
  385        *
  386        * <p> To compare  two nanoT ime values
  387        *  <p re> {@code
  388        * lon g t0 = Sys tem.nanoTi me();
  389        * ...
  390        * lon g t1 = Sys tem.nanoTi me();}</pr e>
  391        *
  392        * one  should us e {@code t 1 - t0 < 0 }, not {@c ode t1 < t 0},
  393        * bec ause of th e possibil ity of num erical ove rflow.
  394        *
  395        * @re turn the c urrent val ue of the  running Ja va Virtual  Machine's
  396        *          high- resolution  time sour ce, in nan oseconds
  397        * @si nce 1.5
  398        */
  399       public  static na tive long  nanoTime() ;
  400  
  401       /**
  402        * Cop ies an arr ay from th e specifie d source a rray, begi nning at t he
  403        * spe cified pos ition, to  the specif ied positi on of the  destinatio n array.
  404        * A s ubsequence  of array  components  are copie d from the  source
  405        * arr ay referen ced by <co de>src</co de> to the  destinati on array
  406        * ref erenced by  <code>des t</code>.  The number  of compon ents copie d is
  407        * equ al to the  <code>leng th</code>  argument.  The compon ents at
  408        * pos itions <co de>srcPos< /code> thr ough
  409        * <co de>srcPos+ length-1</ code> in t he source  array are  copied int o
  410        * pos itions <co de>destPos </code> th rough
  411        * <co de>destPos +length-1< /code>, re spectively , of the d estination
  412        * arr ay.
  413        * <p>
  414        * If  the <code> src</code>  and <code >dest</cod e> argumen ts refer t o the
  415        * sam e array ob ject, then  the copyi ng is perf ormed as i f the
  416        * com ponents at  positions  <code>src Pos</code>  through
  417        * <co de>srcPos+ length-1</ code> were  first cop ied to a t emporary
  418        * arr ay with <c ode>length </code> co mponents a nd then th e contents  of
  419        * the  temporary  array wer e copied i nto positi ons
  420        * <co de>destPos </code> th rough <cod e>destPos+ length-1</ code> of t he
  421        * des tination a rray.
  422        * <p>
  423        * If  <code>dest </code> is  <code>nul l</code>,  then a
  424        * <co de>NullPoi nterExcept ion</code>  is thrown .
  425        * <p>
  426        * If  <code>src< /code> is  <code>null </code>, t hen a
  427        * <co de>NullPoi nterExcept ion</code>  is thrown  and the d estination
  428        * arr ay is not  modified.
  429        * <p>
  430        * Oth erwise, if  any of th e followin g is true,  an
  431        * <co de>ArraySt oreExcepti on</code>  is thrown  and the de stination  is
  432        * not  modified:
  433        * <ul >
  434        * <li >The <code >src</code > argument  refers to  an object  that is n ot an
  435        *      array.
  436        * <li >The <code >dest</cod e> argumen t refers t o an objec t that is  not an
  437        *      array.
  438        * <li >The <code >src</code > argument  and <code >dest</cod e> argumen t refer
  439        *      to arrays  whose com ponent typ es are dif ferent pri mitive typ es.
  440        * <li >The <code >src</code > argument  refers to  an array  with a pri mitive
  441        *     component  type and t he <code>d est</code>  argument  refers to  an array
  442        *      with a re ference co mponent ty pe.
  443        * <li >The <code >src</code > argument  refers to  an array  with a ref erence
  444        *     component  type and t he <code>d est</code>  argument  refers to  an array
  445        *      with a pr imitive co mponent ty pe.
  446        * </u l>
  447        * <p>
  448        * Oth erwise, if  any of th e followin g is true,  an
  449        * <co de>IndexOu tOfBoundsE xception</ code> is
  450        * thr own and th e destinat ion is not  modified:
  451        * <ul >
  452        * <li >The <code >srcPos</c ode> argum ent is neg ative.
  453        * <li >The <code >destPos</ code> argu ment is ne gative.
  454        * <li >The <code >length</c ode> argum ent is neg ative.
  455        * <li ><code>src Pos+length </code> is  greater t han
  456        *      <code>src .length</c ode>, the  length of  the source  array.
  457        * <li ><code>des tPos+lengt h</code> i s greater  than
  458        *      <code>des t.length</ code>, the  length of  the desti nation arr ay.
  459        * </u l>
  460        * <p>
  461        * Oth erwise, if  any actua l componen t of the s ource arra y from
  462        * pos ition <cod e>srcPos</ code> thro ugh
  463        * <co de>srcPos+ length-1</ code> cann ot be conv erted to t he compone nt
  464        * typ e of the d estination  array by  assignment  conversio n, an
  465        * <co de>ArraySt oreExcepti on</code>  is thrown.  In this c ase, let
  466        * <b> <i>k</i></ b> be the  smallest n onnegative  integer l ess than
  467        * len gth such t hat <code> src[srcPos +</code><i >k</i><cod e>]</code>
  468        * can not be con verted to  the compon ent type o f the dest ination
  469        * arr ay; when t he excepti on is thro wn, source  array com ponents fr om
  470        * pos itions <co de>srcPos< /code> thr ough
  471        * <co de>srcPos+ </code><i> k</i><code >-1</code>
  472        * wil l already  have been  copied to  destinatio n array po sitions
  473        * <co de>destPos </code> th rough
  474        * <co de>destPos +</code><i >k</I><cod e>-1</code > and no o ther
  475        * pos itions of  the destin ation arra y will hav e been mod ified.
  476        * (Be cause of t he restric tions alre ady itemiz ed, this
  477        * par agraph eff ectively a pplies onl y to the s ituation w here both
  478        * arr ays have c omponent t ypes that  are refere nce types. )
  479        *
  480        * @pa ram      s rc      th e source a rray.
  481        * @pa ram      s rcPos   st arting pos ition in t he source  array.
  482        * @pa ram      d est     th e destinat ion array.
  483        * @pa ram      d estPos  st arting pos ition in t he destina tion data.
  484        * @pa ram      l ength   th e number o f array el ements to  be copied.
  485        * @ex ception  I ndexOutOfB oundsExcep tion  if c opying wou ld cause
  486        *                 access of  data outs ide array  bounds.
  487        * @ex ception  A rrayStoreE xception   if an elem ent in the  <code>src </code>
  488        *                 array cou ld not be  stored int o the <cod e>dest</co de> array
  489        *                 because o f a type m ismatch.
  490        * @ex ception  N ullPointer Exception  if either  <code>src< /code> or
  491        *                 <code>des t</code> i s <code>nu ll</code>.
  492        */
  493       public  static na tive void  arraycopy( Object src ,  int  sr cPos,
  494                                               Object des t, int des tPos,
  495                                               int length );
  496  
  497       /**
  498        * Ret urns the s ame hash c ode for th e given ob ject as
  499        * wou ld be retu rned by th e default  method has hCode(),
  500        * whe ther or no t the give n object's  class ove rrides
  501        * has hCode().
  502        * The  hash code  for the n ull refere nce is zer o.
  503        *
  504        * @pa ram x obje ct for whi ch the has hCode is t o be calcu lated
  505        * @re turn  the  hashCode
  506        * @si nce   JDK1 .1
  507        */
  508       public  static na tive int i dentityHas hCode(Obje ct x);
  509  
  510       /**
  511        * Sys tem proper ties. The  following  properties  are guara nteed to b e defined:
  512        * <dl >
  513        * <dt >java.vers ion          <dd>Java  version n umber
  514        * <dt >java.vend or           <dd>Java  vendor sp ecific str ing
  515        * <dt >java.vend or.url       <dd>Java  vendor UR L
  516        * <dt >java.home              <dd>Java  installat ion direct ory
  517        * <dt >java.clas s.version    <dd>Java  class ver sion numbe r
  518        * <dt >java.clas s.path       <dd>Java  classpath
  519        * <dt >os.name                <dd>Oper ating Syst em Name
  520        * <dt >os.arch                <dd>Oper ating Syst em Archite cture
  521        * <dt >os.versio n            <dd>Oper ating Syst em Version
  522        * <dt >file.sepa rator        <dd>File  separator  ("/" on U nix)
  523        * <dt >path.sepa rator        <dd>Path  separator  (":" on U nix)
  524        * <dt >line.sepa rator        <dd>Line  separator  ("\n" on  Unix)
  525        * <dt >user.name              <dd>User  account n ame
  526        * <dt >user.home              <dd>User  home dire ctory
  527        * <dt >user.dir               <dd>User 's current  working d irectory
  528        * </d l>
  529        */
  530  
  531       privat e static P roperties  props;
  532       privat e static n ative Prop erties ini tPropertie s(Properti es props);
  533  
  534       /**
  535        * Det ermines th e current  system pro perties.
  536        * <p>
  537        * Fir st, if the re is a se curity man ager, its
  538        * <co de>checkPr opertiesAc cess</code > method i s called w ith no
  539        * arg uments. Th is may res ult in a s ecurity ex ception.
  540        * <p>
  541        * The  current s et of syst em propert ies for us e by the
  542        * {@l ink #getPr operty(Str ing)} meth od is retu rned as a
  543        * <co de>Propert ies</code>  object. I f there is  no curren t set of
  544        * sys tem proper ties, a se t of syste m properti es is firs t created  and
  545        * ini tialized.  This set o f system p roperties  always inc ludes valu es
  546        * for  the follo wing keys:
  547        * <ta ble summar y="Shows p roperty ke ys and ass ociated va lues">
  548        * <tr ><th>Key</ th>
  549        *      <th>Descr iption of  Associated  Value</th ></tr>
  550        * <tr ><td><code >java.vers ion</code> </td>
  551        *      <td>Java  Runtime En vironment  version</t d></tr>
  552        * <tr ><td><code >java.vend or</code>< /td>
  553        *      <td>Java  Runtime En vironment  vendor</td ></tr>
  554        * <tr ><td><code >java.vend or.url</co de></td>
  555        *      <td>Java  vendor URL </td></tr>
  556        * <tr ><td><code >java.home </code></t d>
  557        *      <td>Java  installati on directo ry</td></t r>
  558        * <tr ><td><code >java.vm.s pecificati on.version </code></t d>
  559        *      <td>Java  Virtual Ma chine spec ification  version</t d></tr>
  560        * <tr ><td><code >java.vm.s pecificati on.vendor< /code></td >
  561        *      <td>Java  Virtual Ma chine spec ification  vendor</td ></tr>
  562        * <tr ><td><code >java.vm.s pecificati on.name</c ode></td>
  563        *      <td>Java  Virtual Ma chine spec ification  name</td>< /tr>
  564        * <tr ><td><code >java.vm.v ersion</co de></td>
  565        *      <td>Java  Virtual Ma chine impl ementation  version</ td></tr>
  566        * <tr ><td><code >java.vm.v endor</cod e></td>
  567        *      <td>Java  Virtual Ma chine impl ementation  vendor</t d></tr>
  568        * <tr ><td><code >java.vm.n ame</code> </td>
  569        *      <td>Java  Virtual Ma chine impl ementation  name</td> </tr>
  570        * <tr ><td><code >java.spec ification. version</c ode></td>
  571        *      <td>Java  Runtime En vironment  specificat ion  versi on</td></t r>
  572        * <tr ><td><code >java.spec ification. vendor</co de></td>
  573        *      <td>Java  Runtime En vironment  specificat ion  vendo r</td></tr >
  574        * <tr ><td><code >java.spec ification. name</code ></td>
  575        *      <td>Java  Runtime En vironment  specificat ion  name< /td></tr>
  576        * <tr ><td><code >java.clas s.version< /code></td >
  577        *      <td>Java  class form at version  number</t d></tr>
  578        * <tr ><td><code >java.clas s.path</co de></td>
  579        *      <td>Java  class path </td></tr>
  580        * <tr ><td><code >java.libr ary.path</ code></td>
  581        *      <td>List  of paths t o search w hen loadin g librarie s</td></tr >
  582        * <tr ><td><code >java.io.t mpdir</cod e></td>
  583        *      <td>Defau lt temp fi le path</t d></tr>
  584        * <tr ><td><code >java.comp iler</code ></td>
  585        *      <td>Name  of JIT com piler to u se</td></t r>
  586        * <tr ><td><code >java.ext. dirs</code ></td>
  587        *      <td>Path  of extensi on directo ry or dire ctories
  588        *          <b>De precated.< /b> <i>Thi s property , and the  mechanism
  589        *             wh ich implem ents it, m ay be remo ved in a f uture
  590        *             re lease.</i>  </td></tr >
  591        * <tr ><td><code >os.name</ code></td>
  592        *      <td>Opera ting syste m name</td ></tr>
  593        * <tr ><td><code >os.arch</ code></td>
  594        *      <td>Opera ting syste m architec ture</td>< /tr>
  595        * <tr ><td><code >os.versio n</code></ td>
  596        *      <td>Opera ting syste m version< /td></tr>
  597        * <tr ><td><code >file.sepa rator</cod e></td>
  598        *      <td>File  separator  ("/" on UN IX)</td></ tr>
  599        * <tr ><td><code >path.sepa rator</cod e></td>
  600        *      <td>Path  separator  (":" on UN IX)</td></ tr>
  601        * <tr ><td><code >line.sepa rator</cod e></td>
  602        *      <td>Line  separator  ("\n" on U NIX)</td>< /tr>
  603        * <tr ><td><code >user.name </code></t d>
  604        *      <td>User' s account  name</td>< /tr>
  605        * <tr ><td><code >user.home </code></t d>
  606        *      <td>User' s home dir ectory</td ></tr>
  607        * <tr ><td><code >user.dir< /code></td >
  608        *      <td>User' s current  working di rectory</t d></tr>
  609        * </t able>
  610        * <p>
  611        * Mul tiple path s in a sys tem proper ty value a re separat ed by the  path
  612        * sep arator cha racter of  the platfo rm.
  613        * <p>
  614        * Not e that eve n if the s ecurity ma nager does  not permi t the
  615        * <co de>getProp erties</co de> operat ion, it ma y choose t o permit t he
  616        * {@l ink #getPr operty(Str ing)} oper ation.
  617        *
  618        * @re turn     t he system  properties
  619        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  620        *              < code>check Properties Access</co de> method  doesn't a llow acces s
  621        *                to the sys tem proper ties.
  622        * @se e        # setPropert ies
  623        * @se e        j ava.lang.S ecurityExc eption
  624        * @se e        j ava.lang.S ecurityMan ager#check Properties Access()
  625        * @se e        j ava.util.P roperties
  626        */
  627       public  static Pr operties g etProperti es() {
  628           Se curityMana ger sm = g etSecurity Manager();
  629           if  (sm != nu ll) {
  630                sm.check Properties Access();
  631           }
  632  
  633           re turn props ;
  634       }
  635  
  636       /**
  637        * Ret urns the s ystem-depe ndent line  separator  string.   It always
  638        * ret urns the s ame value  - the init ial value  of the {@l inkplain
  639        * #ge tProperty( String) sy stem prope rty} {@cod e line.sep arator}.
  640        *
  641        * <p> On UNIX sy stems, it  returns {@ code "\n"} ; on Micro soft
  642        * Win dows syste ms it retu rns {@code  "\r\n"}.
  643        *
  644        * @re turn the s ystem-depe ndent line  separator  string
  645        * @si nce 1.7
  646        */
  647       public  static St ring lineS eparator()  {
  648           re turn lineS eparator;
  649       }
  650  
  651       privat e static S tring line Separator;
  652  
  653       /**
  654        * Set s the syst em propert ies to the  <code>Pro perties</c ode>
  655        * arg ument.
  656        * <p>
  657        * Fir st, if the re is a se curity man ager, its
  658        * <co de>checkPr opertiesAc cess</code > method i s called w ith no
  659        * arg uments. Th is may res ult in a s ecurity ex ception.
  660        * <p>
  661        * The  argument  becomes th e current  set of sys tem proper ties for u se
  662        * by  the {@link  #getPrope rty(String )} method.  If the ar gument is
  663        * <co de>null</c ode>, then  the curre nt set of  system pro perties is
  664        * for gotten.
  665        *
  666        * @pa ram      p rops   the  new syste m properti es.
  667        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  668        *              < code>check Properties Access</co de> method  doesn't a llow acces s
  669        *                to the sys tem proper ties.
  670        * @se e        # getPropert ies
  671        * @se e        j ava.util.P roperties
  672        * @se e        j ava.lang.S ecurityExc eption
  673        * @se e        j ava.lang.S ecurityMan ager#check Properties Access()
  674        */
  675       public  static vo id setProp erties(Pro perties pr ops) {
  676           Se curityMana ger sm = g etSecurity Manager();
  677           if  (sm != nu ll) {
  678                sm.check Properties Access();
  679           }
  680           if  (props ==  null) {
  681                props =  new Proper ties();
  682                initProp erties(pro ps);
  683           }
  684           Sy stem.props  = props;
  685       }
  686  
  687       /**
  688        * Get s the syst em propert y indicate d by the s pecified k ey.
  689        * <p>
  690        * Fir st, if the re is a se curity man ager, its
  691        * <co de>checkPr opertyAcce ss</code>  method is  called wit h the key  as
  692        * its  argument.  This may  result in  a Security Exception.
  693        * <p>
  694        * If  there is n o current  set of sys tem proper ties, a se t of syste m
  695        * pro perties is  first cre ated and i nitialized  in the sa me manner  as
  696        * for  the <code >getProper ties</code > method.
  697        *
  698        * @pa ram      k ey   the n ame of the  system pr operty.
  699        * @re turn     t he string  value of t he system  property,
  700        *              o r <code>nu ll</code>  if there i s no prope rty with t hat key.
  701        *
  702        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  703        *              < code>check PropertyAc cess</code > method d oesn't all ow
  704        *                access to  the specif ied system  property.
  705        * @ex ception  N ullPointer Exception  if <code>k ey</code>  is
  706        *              < code>null< /code>.
  707        * @ex ception  I llegalArgu mentExcept ion if <co de>key</co de> is emp ty.
  708        * @se e        # setPropert y
  709        * @se e        j ava.lang.S ecurityExc eption
  710        * @se e        j ava.lang.S ecurityMan ager#check PropertyAc cess(java. lang.Strin g)
  711        * @se e        j ava.lang.S ystem#getP roperties( )
  712        */
  713       public  static St ring getPr operty(Str ing key) {
  714           ch eckKey(key );
  715           Se curityMana ger sm = g etSecurity Manager();
  716           if  (sm != nu ll) {
  717                sm.check PropertyAc cess(key);
  718           }
  719  
  720           re turn props .getProper ty(key);
  721       }
  722  
  723       /**
  724        * Get s the syst em propert y indicate d by the s pecified k ey.
  725        * <p>
  726        * Fir st, if the re is a se curity man ager, its
  727        * <co de>checkPr opertyAcce ss</code>  method is  called wit h the
  728        * <co de>key</co de> as its  argument.
  729        * <p>
  730        * If  there is n o current  set of sys tem proper ties, a se t of syste m
  731        * pro perties is  first cre ated and i nitialized  in the sa me manner  as
  732        * for  the <code >getProper ties</code > method.
  733        *
  734        * @pa ram      k ey   the n ame of the  system pr operty.
  735        * @pa ram      d ef   a def ault value .
  736        * @re turn     t he string  value of t he system  property,
  737        *              o r the defa ult value  if there i s no prope rty with t hat key.
  738        *
  739        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  740        *              < code>check PropertyAc cess</code > method d oesn't all ow
  741        *              a ccess to t he specifi ed system  property.
  742        * @ex ception  N ullPointer Exception  if <code>k ey</code>  is
  743        *              < code>null< /code>.
  744        * @ex ception  I llegalArgu mentExcept ion if <co de>key</co de> is emp ty.
  745        * @se e        # setPropert y
  746        * @se e        j ava.lang.S ecurityMan ager#check PropertyAc cess(java. lang.Strin g)
  747        * @se e        j ava.lang.S ystem#getP roperties( )
  748        */
  749       public  static St ring getPr operty(Str ing key, S tring def)  {
  750           ch eckKey(key );
  751           Se curityMana ger sm = g etSecurity Manager();
  752           if  (sm != nu ll) {
  753                sm.check PropertyAc cess(key);
  754           }
  755  
  756           re turn props .getProper ty(key, de f);
  757       }
  758  
  759       /**
  760        * Set s the syst em propert y indicate d by the s pecified k ey.
  761        * <p>
  762        * Fir st, if a s ecurity ma nager exis ts, its
  763        * <co de>Securit yManager.c heckPermis sion</code > method
  764        * is  called wit h a <code> PropertyPe rmission(k ey, "write ")</code>
  765        * per mission. T his may re sult in a  SecurityEx ception be ing thrown .
  766        * If  no excepti on is thro wn, the sp ecified pr operty is  set to the  given
  767        * val ue.
  768        * <p>
  769        *
  770        * @pa ram      k ey   the n ame of the  system pr operty.
  771        * @pa ram      v alue the v alue of th e system p roperty.
  772        * @re turn     t he previou s value of  the syste m property ,
  773        *              o r <code>nu ll</code>  if it did  not have o ne.
  774        *
  775        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  776        *              < code>check Permission </code> me thod doesn 't allow
  777        *              s etting of  the specif ied proper ty.
  778        * @ex ception  N ullPointer Exception  if <code>k ey</code>  or
  779        *              < code>value </code> is  <code>nul l</code>.
  780        * @ex ception  I llegalArgu mentExcept ion if <co de>key</co de> is emp ty.
  781        * @se e        # getPropert y
  782        * @se e        j ava.lang.S ystem#getP roperty(ja va.lang.St ring)
  783        * @se e        j ava.lang.S ystem#getP roperty(ja va.lang.St ring, java .lang.Stri ng)
  784        * @se e        j ava.util.P ropertyPer mission
  785        * @se e        S ecurityMan ager#check Permission
  786        * @si nce      1 .2
  787        */
  788       public  static St ring setPr operty(Str ing key, S tring valu e) {
  789           ch eckKey(key );
  790           Se curityMana ger sm = g etSecurity Manager();
  791           if  (sm != nu ll) {
  792                sm.check Permission (new Prope rtyPermiss ion(key,
  793                    Secu rityConsta nts.PROPER TY_WRITE_A CTION));
  794           }
  795  
  796           re turn (Stri ng) props. setPropert y(key, val ue);
  797       }
  798  
  799       /**
  800        * Rem oves the s ystem prop erty indic ated by th e specifie d key.
  801        * <p>
  802        * Fir st, if a s ecurity ma nager exis ts, its
  803        * <co de>Securit yManager.c heckPermis sion</code > method
  804        * is  called wit h a <code> PropertyPe rmission(k ey, "write ")</code>
  805        * per mission. T his may re sult in a  SecurityEx ception be ing thrown .
  806        * If  no excepti on is thro wn, the sp ecified pr operty is  removed.
  807        * <p>
  808        *
  809        * @pa ram      k ey   the n ame of the  system pr operty to  be removed .
  810        * @re turn     t he previou s string v alue of th e system p roperty,
  811        *              o r <code>nu ll</code>  if there w as no prop erty with  that key.
  812        *
  813        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  814        *              < code>check PropertyAc cess</code > method d oesn't all ow
  815        *                access to  the specif ied system  property.
  816        * @ex ception  N ullPointer Exception  if <code>k ey</code>  is
  817        *              < code>null< /code>.
  818        * @ex ception  I llegalArgu mentExcept ion if <co de>key</co de> is emp ty.
  819        * @se e        # getPropert y
  820        * @se e        # setPropert y
  821        * @se e        j ava.util.P roperties
  822        * @se e        j ava.lang.S ecurityExc eption
  823        * @se e        j ava.lang.S ecurityMan ager#check Properties Access()
  824        * @si nce 1.5
  825        */
  826       public  static St ring clear Property(S tring key)  {
  827           ch eckKey(key );
  828           Se curityMana ger sm = g etSecurity Manager();
  829           if  (sm != nu ll) {
  830                sm.check Permission (new Prope rtyPermiss ion(key, " write"));
  831           }
  832  
  833           re turn (Stri ng) props. remove(key );
  834       }
  835  
  836       privat e static v oid checkK ey(String  key) {
  837           if  (key == n ull) {
  838                throw ne w NullPoin terExcepti on("key ca n't be nul l");
  839           }
  840           if  (key.equa ls("")) {
  841                throw ne w IllegalA rgumentExc eption("ke y can't be  empty");
  842           }
  843       }
  844  
  845       /**
  846        * Get s the valu e of the s pecified e nvironment  variable.  An
  847        * env ironment v ariable is  a system- dependent  external n amed
  848        * val ue.
  849        *
  850        * <p> If a secur ity manage r exists,  its
  851        * {@l ink Securi tyManager# checkPermi ssion chec kPermissio n}
  852        * met hod is cal led with a
  853        * <co de>{@link  RuntimePer mission}(" getenv."+n ame)</code >
  854        * per mission.   This may r esult in a  {@link Se curityExce ption}
  855        * bei ng thrown.   If no ex ception is  thrown th e value of  the
  856        * var iable <cod e>name</co de> is ret urned.
  857        *
  858        * <p> <a name="E nvironment VSSystemPr operties"> <i>System
  859        * pro perties</i > and <i>e nvironment  variables </i></a> a re both
  860        * con ceptually  mappings b etween nam es and val ues.  Both
  861        * mec hanisms ca n be used  to pass us er-defined  informati on to a
  862        * Jav a process.   Environm ent variab les have a  more glob al effect,
  863        * bec ause they  are visibl e to all d escendants  of the pr ocess
  864        * whi ch defines  them, not  just the  immediate  Java subpr ocess.
  865        * The y can have  subtly di fferent se mantics, s uch as cas e
  866        * ins ensitivity , on diffe rent opera ting syste ms.  For t hese
  867        * rea sons, envi ronment va riables ar e more lik ely to hav e
  868        * uni ntended si de effects .  It is b est to use  system pr operties
  869        * whe re possibl e.  Enviro nment vari ables shou ld be used  when a
  870        * glo bal effect  is desire d, or when  an extern al system  interface
  871        * req uires an e nvironment  variable  (such as < code>PATH< /code>).
  872        *
  873        * <p> On UNIX sy stems the  alphabetic  case of < code>name< /code> is
  874        * typ ically sig nificant,  while on M icrosoft W indows sys tems it is
  875        * typ ically not .  For exa mple, the  expression
  876        * <co de>System. getenv("FO O").equals (System.ge tenv("foo" ))</code>
  877        * is  likely to  be true on  Microsoft  Windows.
  878        *
  879        * @pa ram  name  the name o f the envi ronment va riable
  880        * @re turn the s tring valu e of the v ariable, o r <code>nu ll</code>
  881        *          if th e variable  is not de fined in t he system  environmen t
  882        * @th rows NullP ointerExce ption if < code>name< /code> is  <code>null </code>
  883        * @th rows Secur ityExcepti on
  884        *          if a  security m anager exi sts and it s
  885        *          {@lin k Security Manager#ch eckPermiss ion checkP ermission}
  886        *          metho d doesn't  allow acce ss to the  environmen t variable
  887        *          <code >name</cod e>
  888        * @se e    #gete nv()
  889        * @se e    Proce ssBuilder# environmen t()
  890        */
  891       public  static St ring geten v(String n ame) {
  892           Se curityMana ger sm = g etSecurity Manager();
  893           if  (sm != nu ll) {
  894                sm.check Permission (new Runti mePermissi on("getenv ."+name));
  895           }
  896  
  897           re turn Proce ssEnvironm ent.getenv (name);
  898       }
  899  
  900  
  901       /**
  902        * Ret urns an un modifiable  string ma p view of  the curren t system e nvironment .
  903        * The  environme nt is a sy stem-depen dent mappi ng from na mes to
  904        * val ues which  is passed  from paren t to child  processes .
  905        *
  906        * <p> If the sys tem does n ot support  environme nt variabl es, an
  907        * emp ty map is  returned.
  908        *
  909        * <p> The return ed map wil l never co ntain null  keys or v alues.
  910        * Att empting to  query the  presence  of a null  key or val ue will
  911        * thr ow a {@lin k NullPoin terExcepti on}.  Atte mpting to  query
  912        * the  presence  of a key o r value wh ich is not  of type
  913        * {@l ink String } will thr ow a {@lin k ClassCas tException }.
  914        *
  915        * <p> The return ed map and  its colle ction view s may not  obey the
  916        * gen eral contr act of the  {@link Ob ject#equal s} and
  917        * {@l ink Object #hashCode}  methods.
  918        *
  919        * <p> The return ed map is  typically  case-sensi tive on al l platform s.
  920        *
  921        * <p> If a secur ity manage r exists,  its
  922        * {@l ink Securi tyManager# checkPermi ssion chec kPermissio n}
  923        * met hod is cal led with a
  924        * <co de>{@link  RuntimePer mission}(" getenv.*") </code>
  925        * per mission.   This may r esult in a  {@link Se curityExce ption} bei ng
  926        * thr own.
  927        *
  928        * <p> When passi ng informa tion to a  Java subpr ocess,
  929        * <a  href=#Envi ronmentVSS ystemPrope rties>syst em propert ies</a>
  930        * are  generally  preferred  over envi ronment va riables.
  931        *
  932        * @re turn the e nvironment  as a map  of variabl e names to  values
  933        * @th rows Secur ityExcepti on
  934        *          if a  security m anager exi sts and it s
  935        *          {@lin k Security Manager#ch eckPermiss ion checkP ermission}
  936        *          metho d doesn't  allow acce ss to the  process en vironment
  937        * @se e    #gete nv(String)
  938        * @se e    Proce ssBuilder# environmen t()
  939        * @si nce  1.5
  940        */
  941       public  static ja va.util.Ma p<String,S tring> get env() {
  942           Se curityMana ger sm = g etSecurity Manager();
  943           if  (sm != nu ll) {
  944                sm.check Permission (new Runti mePermissi on("getenv .*"));
  945           }
  946  
  947           re turn Proce ssEnvironm ent.getenv ();
  948       }
  949  
  950       /**
  951        * Ter minates th e currentl y running  Java Virtu al Machine . The
  952        * arg ument serv es as a st atus code;  by conven tion, a no nzero stat us
  953        * cod e indicate s abnormal  terminati on.
  954        * <p>
  955        * Thi s method c alls the < code>exit< /code> met hod in cla ss
  956        * <co de>Runtime </code>. T his method  never ret urns norma lly.
  957        * <p>
  958        * The  call <cod e>System.e xit(n)</co de> is eff ectively e quivalent  to
  959        * the  call:
  960        * <bl ockquote>< pre>
  961        * Run time.getRu ntime().ex it(n)
  962        * </p re></block quote>
  963        *
  964        * @pa ram      s tatus   ex it status.
  965        * @th rows  Secu rityExcept ion
  966        *         if a s ecurity ma nager exis ts and its  <code>che ckExit</co de>
  967        *         method  doesn't a llow exit  with the s pecified s tatus.
  968        * @se e        j ava.lang.R untime#exi t(int)
  969        */
  970       public  static vo id exit(in t status)  {
  971           Ru ntime.getR untime().e xit(status );
  972       }
  973  
  974       /**
  975        * Run s the garb age collec tor.
  976        * <p>
  977        * Cal ling the < code>gc</c ode> metho d suggests  that the  Java Virtu al
  978        * Mac hine expen d effort t oward recy cling unus ed objects  in order  to
  979        * mak e the memo ry they cu rrently oc cupy avail able for q uick reuse .
  980        * Whe n control  returns fr om the met hod call,  the Java V irtual
  981        * Mac hine has m ade a best  effort to  reclaim s pace from  all discar ded
  982        * obj ects.
  983        * <p>
  984        * The  call <cod e>System.g c()</code>  is effect ively equi valent to  the
  985        * cal l:
  986        * <bl ockquote>< pre>
  987        * Run time.getRu ntime().gc ()
  988        * </p re></block quote>
  989        *
  990        * @se e     java .lang.Runt ime#gc()
  991        */
  992       public  static vo id gc() {
  993           Ru ntime.getR untime().g c();
  994       }
  995  
  996       /**
  997        * Run s the fina lization m ethods of  any object s pending  finalizati on.
  998        * <p>
  999        * Cal ling this  method sug gests that  the Java  Virtual Ma chine expe nd
  1000        * eff ort toward  running t he <code>f inalize</c ode> metho ds of obje cts
  1001        * tha t have bee n found to  be discar ded but wh ose <code> finalize</ code>
  1002        * met hods have  not yet be en run. Wh en control  returns f rom the
  1003        * met hod call,  the Java V irtual Mac hine has m ade a best  effort to
  1004        * com plete all  outstandin g finaliza tions.
  1005        * <p>
  1006        * The  call <cod e>System.r unFinaliza tion()</co de> is eff ectively
  1007        * equ ivalent to  the call:
  1008        * <bl ockquote>< pre>
  1009        * Run time.getRu ntime().ru nFinalizat ion()
  1010        * </p re></block quote>
  1011        *
  1012        * @se e     java .lang.Runt ime#runFin alization( )
  1013        */
  1014       public  static vo id runFina lization()  {
  1015           Ru ntime.getR untime().r unFinaliza tion();
  1016       }
  1017  
  1018       /**
  1019        * Ena ble or dis able final ization on  exit; doi ng so spec ifies that  the
  1020        * fin alizers of  all objec ts that ha ve finaliz ers that h ave not ye t been
  1021        * aut omatically  invoked a re to be r un before  the Java r untime exi ts.
  1022        * By  default, f inalizatio n on exit  is disable d.
  1023        *
  1024        * <p> If there i s a securi ty manager ,
  1025        * its  <code>che ckExit</co de> method  is first  called
  1026        * wit h 0 as its  argument  to ensure  the exit i s allowed.
  1027        * Thi s could re sult in a  SecurityEx ception.
  1028        *
  1029        * @de precated   This metho d is inher ently unsa fe.  It ma y result i n
  1030        *       finalize rs being c alled on l ive object s while ot her thread s are
  1031        *       concurre ntly manip ulating th ose object s, resulti ng in erra tic
  1032        *       behavior  or deadlo ck.
  1033        * @pa ram value  indicating  enabling  or disabli ng of fina lization
  1034        * @th rows  Secu rityExcept ion
  1035        *         if a s ecurity ma nager exis ts and its  <code>che ckExit</co de>
  1036        *         method  doesn't a llow the e xit.
  1037        *
  1038        * @se e     java .lang.Runt ime#exit(i nt)
  1039        * @se e     java .lang.Runt ime#gc()
  1040        * @se e     java .lang.Secu rityManage r#checkExi t(int)
  1041        * @si nce   JDK1 .1
  1042        */
  1043       @Depre cated
  1044       public  static vo id runFina lizersOnEx it(boolean  value) {
  1045           Ru ntime.runF inalizersO nExit(valu e);
  1046       }
  1047  
  1048       /**
  1049        * Loa ds the nat ive librar y specifie d by the f ilename ar gument.  T he filenam e
  1050        * arg ument must  be an abs olute path  name.
  1051        *
  1052        * If  the filena me argumen t, when st ripped of  any platfo rm-specifi c library
  1053        * pre fix, path,  and file  extension,  indicates  a library  whose nam e is,
  1054        * for  example,  L, and a n ative libr ary called  L is stat ically lin ked
  1055        * wit h the VM,  then the J NI_OnLoad_ L function  exported  by the lib rary
  1056        * is  invoked ra ther than  attempting  to load a  dynamic l ibrary.
  1057        * A f ilename ma tching the  argument  does not h ave to exi st in the
  1058        * fil e system.
  1059        * See  the JNI S pecificati on for mor e details.
  1060        *
  1061        * Oth erwise, th e filename  argument  is mapped  to a nativ e library  image in
  1062        * an  implementa tion-depen dent manne r.
  1063        *
  1064        * <p>
  1065        * The  call <cod e>System.l oad(name)< /code> is  effectivel y equivale nt
  1066        * to  the call:
  1067        * <bl ockquote>< pre>
  1068        * Run time.getRu ntime().lo ad(name)
  1069        * </p re></block quote>
  1070        *
  1071        * @pa ram      f ilename    the file t o load.
  1072        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  1073        *              < code>check Link</code > method d oesn't all ow
  1074        *              l oading of  the specif ied dynami c library
  1075        * @ex ception  U nsatisfied LinkError   if either  the filen ame is not  an
  1076        *              a bsolute pa th name, t he native  library is  not stati cally
  1077        *              l inked with  the VM, o r the libr ary cannot  be mapped  to
  1078        *              a  native li brary imag e by the h ost system .
  1079        * @ex ception  N ullPointer Exception  if <code>f ilename</c ode> is
  1080        *              < code>null< /code>
  1081        * @se e        j ava.lang.R untime#loa d(java.lan g.String)
  1082        * @se e        j ava.lang.S ecurityMan ager#check Link(java. lang.Strin g)
  1083        */
  1084       @Calle rSensitive
  1085       public  static vo id load(St ring filen ame) {
  1086           Ru ntime.getR untime().l oad0(Refle ction.getC allerClass (), filena me);
  1087       }
  1088  
  1089       /**
  1090        * Loa ds the nat ive librar y specifie d by the < code>libna me</code>
  1091        * arg ument.  Th e <code>li bname</cod e> argumen t must not  contain a ny platfor m
  1092        * spe cific pref ix, file e xtension o r path. If  a native  library
  1093        * cal led <code> libname</c ode> is st atically l inked with  the VM, t hen the
  1094        * JNI _OnLoad_<c ode>libnam e</code> f unction ex ported by  the librar y is invok ed.
  1095        * See  the JNI S pecificati on for mor e details.
  1096        *
  1097        * Oth erwise, th e libname  argument i s loaded f rom a syst em library
  1098        * loc ation and  mapped to  a native l ibrary ima ge in an i mplementat ion-
  1099        * dep endent man ner.
  1100        * <p>
  1101        * The  call <cod e>System.l oadLibrary (name)</co de> is eff ectively
  1102        * equ ivalent to  the call
  1103        * <bl ockquote>< pre>
  1104        * Run time.getRu ntime().lo adLibrary( name)
  1105        * </p re></block quote>
  1106        *
  1107        * @pa ram      l ibname   t he name of  the libra ry.
  1108        * @ex ception  S ecurityExc eption  if  a securit y manager  exists and  its
  1109        *              < code>check Link</code > method d oesn't all ow
  1110        *              l oading of  the specif ied dynami c library
  1111        * @ex ception  U nsatisfied LinkError  if either  the libnam e argument
  1112        *              c ontains a  file path,  the nativ e library  is not sta tically
  1113        *              l inked with  the VM,   or the lib rary canno t be mappe d to a
  1114        *              n ative libr ary image  by the hos t system.
  1115        * @ex ception  N ullPointer Exception  if <code>l ibname</co de> is
  1116        *              < code>null< /code>
  1117        * @se e        j ava.lang.R untime#loa dLibrary(j ava.lang.S tring)
  1118        * @se e        j ava.lang.S ecurityMan ager#check Link(java. lang.Strin g)
  1119        */
  1120       @Calle rSensitive
  1121       public  static vo id loadLib rary(Strin g libname)  {
  1122           Ru ntime.getR untime().l oadLibrary 0(Reflecti on.getCall erClass(),  libname);
  1123       }
  1124  
  1125       /**
  1126        * Map s a librar y name int o a platfo rm-specifi c string r epresentin g
  1127        * a n ative libr ary.
  1128        *
  1129        * @pa ram      l ibname the  name of t he library .
  1130        * @re turn     a  platform- dependent  native lib rary name.
  1131        * @ex ception  N ullPointer Exception  if <code>l ibname</co de> is
  1132        *              < code>null< /code>
  1133        * @se e        j ava.lang.S ystem#load Library(ja va.lang.St ring)
  1134        * @se e        j ava.lang.C lassLoader #findLibra ry(java.la ng.String)
  1135        * @si nce      1 .2
  1136        */
  1137       public  static na tive Strin g mapLibra ryName(Str ing libnam e);
  1138  
  1139       /**
  1140        * Cre ate PrintS tream for  stdout/err  based on  encoding.
  1141        */
  1142       privat e static P rintStream  newPrintS tream(File OutputStre am fos, St ring enc)  {
  1143          if  (enc != nu ll) {
  1144                try {
  1145                    retu rn new Pri ntStream(n ew Buffere dOutputStr eam(fos, 1 28), true,  enc);
  1146                } catch  (Unsupport edEncoding Exception  uee) {}
  1147           }
  1148           re turn new P rintStream (new Buffe redOutputS tream(fos,  128), tru e);
  1149       }
  1150  
  1151  
  1152       /**
  1153        * Ini tialize th e system c lass.  Cal led after  thread ini tializatio n.
  1154        */
  1155       privat e static v oid initia lizeSystem Class() {
  1156  
  1157           //  VM might  invoke JNU _NewString Platform()  to set th ose encodi ng
  1158           //  sensitive  propertie s (user.ho me, user.n ame, boot. class.path , etc.)
  1159           //  during "p rops" init ialization , in which  it may ne ed access,  via
  1160           //  System.ge tProperty( ), to the  related sy stem encod ing proper ty that
  1161           //  have been  initializ ed (put in to "props" ) at early  stage of  the
  1162           //  initializ ation. So  make sure  the "props " is avail able at th e
  1163           //  very begi nning of t he initial ization an d all syst em propert ies to
  1164           //  be put in to it dire ctly.
  1165           pr ops = new  Properties ();
  1166           in itProperti es(props);   // initi alized by  the VM
  1167  
  1168           //  There are  certain s ystem conf igurations  that may  be control led by
  1169           //  VM option s such as  the maximu m amount o f direct m emory and
  1170           //  Integer c ache size  used to su pport the  object ide ntity sema ntics
  1171           //  of autobo xing.  Typ ically, th e library  will obtai n these va lues
  1172           //  from the  properties  set by th e VM.  If  the proper ties are f or
  1173           //  internal  implementa tion use o nly, these  propertie s should b e
  1174           //  removed f rom the sy stem prope rties.
  1175           //
  1176           //  See java. lang.Integ er.Integer Cache and  the
  1177           //  sun.misc. VM.saveAnd RemoveProp erties met hod for ex ample.
  1178           //
  1179           //  Save a pr ivate copy  of the sy stem prope rties obje ct that
  1180           //  can only  be accesse d by the i nternal im plementati on.  Remov e
  1181           //  certain s ystem prop erties tha t are not  intended f or public  access.
  1182           su n.misc.VM. saveAndRem ovePropert ies(props) ;
  1183  
  1184  
  1185           li neSeparato r = props. getPropert y("line.se parator");
  1186           su n.misc.Ver sion.init( );
  1187  
  1188           Fi leInputStr eam fdIn =  new FileI nputStream (FileDescr iptor.in);
  1189           Fi leOutputSt ream fdOut  = new Fil eOutputStr eam(FileDe scriptor.o ut);
  1190           Fi leOutputSt ream fdErr  = new Fil eOutputStr eam(FileDe scriptor.e rr);
  1191           se tIn0(new B ufferedInp utStream(f dIn));
  1192           se tOut0(newP rintStream (fdOut, pr ops.getPro perty("sun .stdout.en coding"))) ;
  1193           se tErr0(newP rintStream (fdErr, pr ops.getPro perty("sun .stderr.en coding"))) ;
  1194  
  1195           //  Load the  zip librar y now in o rder to ke ep java.ut il.zip.Zip File
  1196           //  from tryi ng to use  itself to  load this  library la ter.
  1197           lo adLibrary( "zip");
  1198  
  1199           //  Setup Jav a signal h andlers fo r HUP, TER M, and INT  (where av ailable).
  1200           Te rminator.s etup();
  1201  
  1202           //  Initializ e any misc ellenous o perating s ystem sett ings that  need to be
  1203           //  set for t he class l ibraries.  Currently  this is no -op everyw here excep t
  1204           //  for Windo ws where t he process -wide erro r mode is  set before  the java. io
  1205           //  classes a re used.
  1206           su n.misc.VM. initialize OSEnvironm ent();
  1207  
  1208           //  The main  thread is  not added  to its thr ead group  in the sam e
  1209           //  way as ot her thread s; we must  do it our selves her e.
  1210           Th read curre nt = Threa d.currentT hread();
  1211           cu rrent.getT hreadGroup ().add(cur rent);
  1212  
  1213             // registe r shared  PW      s
  1214           se tJavaLangA ccess();
  1215  
  1216           //  Subsystem s that are  invoked d uring init ialization  can invok e
  1217           //  sun.misc. VM.isBoote d() in ord er to avoi d doing th ings that  should
  1218           //  wait unti l the appl ication cl ass loader  has been  set up.
  1219           //  IMPORTANT : Ensure t hat this r emains the  last init ialization  action!
  1220           su n.misc.VM. booted();
  1221       }
  1222  
  1223       privat e static v oid setJav aLangAcces s() {
  1224           //  Allow pri vileged cl asses outs ide of jav a.lang
  1225           su n.misc.Sha redSecrets .setJavaLa ngAccess(n ew sun.mis c.JavaLang Access(){
  1226                public s un.reflect .ConstantP ool getCon stantPool( Class<?> k lass) {
  1227                    retu rn klass.g etConstant Pool();
  1228                }
  1229                public b oolean cas Annotation Type(Class <?> klass,  Annotatio nType oldT ype, Annot ationType  newType) {
  1230                    retu rn klass.c asAnnotati onType(old Type, newT ype);
  1231                }
  1232                public A nnotationT ype getAnn otationTyp e(Class<?>  klass) {
  1233                    retu rn klass.g etAnnotati onType();
  1234                }
  1235                public M ap<Class<?  extends A nnotation> , Annotati on> getDec laredAnnot ationMap(C lass<?> kl ass) {
  1236                    retu rn klass.g etDeclared Annotation Map();
  1237                }
  1238                public b yte[] getR awClassAnn otations(C lass<?> kl ass) {
  1239                    retu rn klass.g etRawAnnot ations();
  1240                }
  1241                public b yte[] getR awClassTyp eAnnotatio ns(Class<? > klass) {
  1242                    retu rn klass.g etRawTypeA nnotations ();
  1243                }
  1244                public b yte[] getR awExecutab leTypeAnno tations(Ex ecutable e xecutable)  {
  1245                    retu rn Class.g etExecutab leTypeAnno tationByte s(executab le);
  1246                }
  1247                public < E extends  Enum<E>>
  1248                         E[] getEnu mConstants Shared(Cla ss<E> klas s) {
  1249                    retu rn klass.g etEnumCons tantsShare d();
  1250                }
  1251                public v oid blocke dOn(Thread  t, Interr uptible b)  {
  1252                    t.bl ockedOn(b) ;
  1253                }
  1254                public v oid regist erShutdown Hook(int s lot, boole an registe rShutdownI nProgress,  Runnable  hook) {
  1255                    Shut down.add(s lot, regis terShutdow nInProgres s, hook);
  1256                }
  1257                public i nt getStac kTraceDept h(Throwabl e t) {
  1258                    retu rn t.getSt ackTraceDe pth();
  1259                }
  1260                public S tackTraceE lement get StackTrace Element(Th rowable t,  int i) {
  1261                    retu rn t.getSt ackTraceEl ement(i);
  1262                }
  1263                public S tring newS tringUnsaf e(char[] c hars) {
  1264                    retu rn new Str ing(chars,  true);
  1265                }
  1266                public T hread newT hreadWithA cc(Runnabl e target,  AccessCont rolContext  acc) {
  1267                    retu rn new Thr ead(target , acc);
  1268                }
  1269                public v oid invoke Finalize(O bject o) t hrows Thro wable {
  1270                    o.fi nalize();
  1271                }
  1272           }) ;
  1273       }
  1274   }