Advertisement
Guest User

some missing parts

a guest
Sep 17th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.54 KB | None | 0 0
  1. diff --git a/vm/JavaAPI/src/java/lang/Byte.java b/vm/JavaAPI/src/java/lang/Byte.java
  2. index 2547124..3713a5e 100644
  3. --- a/vm/JavaAPI/src/java/lang/Byte.java
  4. +++ b/vm/JavaAPI/src/java/lang/Byte.java
  5. @@ -38,6 +38,7 @@ public final class Byte{
  6.       * See Also:Constant Field Values
  7.       */
  8.      public static final byte MIN_VALUE = -128;
  9. +    public static final int SIZE = 8;
  10.  
  11.      private byte value;
  12.      
  13. diff --git a/vm/JavaAPI/src/java/lang/Integer.java b/vm/JavaAPI/src/java/lang/Integer.java
  14. index c833a87..9812077 100644
  15. --- a/vm/JavaAPI/src/java/lang/Integer.java
  16. +++ b/vm/JavaAPI/src/java/lang/Integer.java
  17. @@ -46,6 +46,7 @@ public final class Integer{
  18.       * See Also:Constant Field Values
  19.       */
  20.      public static final int MIN_VALUE=-2147483648;
  21. +    public static final int SIZE=32;
  22.  
  23.      private int value;
  24.      
  25. @@ -199,7 +200,7 @@ public final class Integer{
  26.          }  while ((i >>>= 1) != 0);
  27.  
  28.          //return new String(cursor, bufLen - cursor, buf);
  29. -        return new String(cursor, bufLen - cursor, buf);
  30. +        return new String(buf, cursor, bufLen - cursor);
  31.      }
  32.  
  33.  
  34. @@ -226,7 +227,7 @@ public final class Integer{
  35.              buf[--cursor] = digits[i & 0xf];
  36.          } while ((i >>>= 4) != 0 || (bufLen - cursor < minWidth));
  37.  
  38. -        return new String(cursor, bufLen - cursor, buf);
  39. +        return new String(buf, cursor, bufLen - cursor);
  40.      }
  41.      
  42.      public static String intToOctalString(int i) {
  43. @@ -238,7 +239,7 @@ public final class Integer{
  44.              buf[--cursor] = DIGITS[i & 7];
  45.          } while ((i >>>= 3) != 0);
  46.  
  47. -        return new String(cursor, bufLen - cursor, buf);
  48. +        return new String(buf, cursor, bufLen - cursor);
  49.      }
  50.  
  51.      /**
  52. @@ -322,4 +323,9 @@ public final class Integer{
  53.      public static int signum(int i) {
  54.          return (i >> 31) | (-i >>> 31); // Hacker's delight 2-7
  55.      }
  56. +
  57. +    public static int compare(int x, int y) {
  58. +        return (x < y) ? -1 : ((x == y) ? 0 : 1);
  59. +    }
  60. +
  61.  }
  62. diff --git a/vm/JavaAPI/src/java/lang/Math.java b/vm/JavaAPI/src/java/lang/Math.java
  63. index aac4fd8..a80db95 100644
  64. --- a/vm/JavaAPI/src/java/lang/Math.java
  65. +++ b/vm/JavaAPI/src/java/lang/Math.java
  66. @@ -201,5 +201,14 @@ public final class Math{
  67.          }
  68.          return (int) floor(f + 0.5f);
  69.      }
  70. +
  71. +        public static double signum(double d) {
  72. +                  return (d == 0.0 ? 0 : (d < 0 ? -1 : 1));
  73. +        }
  74. +
  75. +        public static float signum(float d) {
  76. +                  return (d == 0.0 ? 0 : (d < 0 ? -1 : 1));
  77. +        }
  78. +
  79.      
  80.  }
  81. diff --git a/vm/JavaAPI/src/java/lang/String.java b/vm/JavaAPI/src/java/lang/String.java
  82. index 38078f8..ae3b7db 100644
  83. --- a/vm/JavaAPI/src/java/lang/String.java
  84. +++ b/vm/JavaAPI/src/java/lang/String.java
  85. @@ -198,6 +198,9 @@ public final class String implements java.lang.CharSequence, Comparable<String>
  86.          System.arraycopy(str.value, str.offset, n, count, str.count);
  87.          return new String(n);
  88.      }
  89. +    public boolean contains(java.lang.CharSequence instr){
  90. +   return indexOf(instr.toString()) >= 0;
  91. +    }
  92.  
  93.      /**
  94.       * Tests if this string ends with the specified suffix.
  95. @@ -823,6 +826,10 @@ public final class String implements java.lang.CharSequence, Comparable<String>
  96.          return Long.toString(l);
  97.      }
  98.  
  99. +    public boolean isEmpty() {
  100. +        return value.length == 0;
  101. +    }
  102. +
  103.      /**
  104.       * Returns the string representation of the Object argument.
  105.       */
  106. diff --git a/vm/JavaAPI/src/java/lang/System.java b/vm/JavaAPI/src/java/lang/System.java
  107. index 1dc144a..e91c294 100644
  108. --- a/vm/JavaAPI/src/java/lang/System.java
  109. +++ b/vm/JavaAPI/src/java/lang/System.java
  110. @@ -136,7 +136,6 @@ public final class System {
  111.      public static void gc() {
  112.          if(startedGc) {
  113.              forceGc = true;
  114. -            gcShouldLoop = true;
  115.          }
  116.          startGCThread();
  117.          synchronized(LOCK) {
  118. diff --git a/vm/JavaAPI/src/java/lang/Throwable.java b/vm/JavaAPI/src/java/lang/Throwable.java
  119. index d911a16..10f0858 100644
  120. --- a/vm/JavaAPI/src/java/lang/Throwable.java
  121. +++ b/vm/JavaAPI/src/java/lang/Throwable.java
  122. @@ -80,6 +80,10 @@ public class Throwable{
  123.          System.out.println(stack);
  124.      }
  125.  
  126. +    public void printStackTrace(java.io.PrintStream stream){
  127. +        stream.println(stack);
  128. +    }
  129. +
  130.      /**
  131.       * Returns a short description of this Throwable object. If this Throwable object was
  132.       * with an error message string, then the result is the concatenation of three strings: The name of the actual class of this object ": " (a colon and a space) The result of the
  133. diff --git a/vm/JavaAPI/src/java/util/Random.java b/vm/JavaAPI/src/java/util/Random.java
  134. index 6ace608..5edc4dd 100644
  135. --- a/vm/JavaAPI/src/java/util/Random.java
  136. +++ b/vm/JavaAPI/src/java/util/Random.java
  137. @@ -123,4 +123,15 @@ public class Random{
  138.          this.seed = (seed ^ multiplier) & ((1L << 48) - 1);
  139.      }
  140.  
  141. +        public void nextBytes(byte[] bytes) {
  142. +                  for (int i = 0, len = bytes.length; i < len; )
  143. +                                for (int rnd = nextInt(),
  144. +                                                         n = Math.min(len - i, Integer.SIZE/Byte.SIZE);
  145. +                                                                          n-- > 0; rnd >>= Byte.SIZE)
  146. +                                                  bytes[i++] = (byte)rnd;
  147. +                      }
  148. +
  149. +
  150. +
  151. +
  152.  }
  153. diff --git a/vm/JavaAPI/src/java/util/TimeZone.java b/vm/JavaAPI/src/java/util/TimeZone.java
  154. index 0b0e376..1e2fb99 100644
  155. --- a/vm/JavaAPI/src/java/util/TimeZone.java
  156. +++ b/vm/JavaAPI/src/java/util/TimeZone.java
  157. @@ -31,26 +31,26 @@ public abstract class TimeZone{
  158.       * style may yield GMT offsets like {@code GMT-08:00}.
  159.       */
  160.      public static final int SHORT = 0;
  161. -    
  162. +
  163.      /**
  164.       * The long display name style, such as {@code Pacific Daylight Time}.
  165.       * Requests for this style may yield GMT offsets like {@code GMT-08:00}.
  166.       */
  167.      public static final int LONG = 1;
  168. -    
  169. +
  170.      static final TimeZone GMT = new SimpleTimeZone(0, "GMT"); // Greenwich Mean Time
  171. -    
  172. +
  173.      private static TimeZone defaultTimeZone;
  174. -    
  175. +
  176.      private String ID;
  177.  
  178. -    public TimeZone(){        
  179. +    public TimeZone(){
  180.      }
  181.  
  182.      void setID(String id) {
  183.          ID = id;
  184.      }
  185. -    
  186. +
  187.      /**
  188.       * Gets all the available IDs supported.
  189.       */
  190. @@ -102,12 +102,12 @@ public abstract class TimeZone{
  191.      int getDSTSavings() {
  192.          return useDaylightTime() ? 3600000 : 0;
  193.      }
  194. -    
  195. -    
  196. +
  197. +
  198.      boolean inDaylightTime(Date time) {
  199.          return false;
  200.      }
  201. -    
  202. +
  203.      /**
  204.       * Gets the ID of this time zone.
  205.       */
  206. @@ -128,12 +128,53 @@ public abstract class TimeZone{
  207.      /**
  208.       * Gets the TimeZone for the given ID.
  209.       */
  210. -    public static java.util.TimeZone getTimeZone(java.lang.String ID){
  211. -        if(ID != null && ID.equalsIgnoreCase("gmt")) {
  212. -            return GMT;
  213. +    public static java.util.TimeZone getTimeZone(final java.lang.String tzone){
  214. +        if ("UTC".equals(tzone)) {
  215. +            TimeZone tz = new TimeZone() {
  216. +                @Override
  217. +                public int getOffset(int era, int year, int month, int day, int dayOfWeek, int timeOfDayMillis) {
  218. +                    return 0;
  219. +                }
  220. +
  221. +                @Override
  222. +                public int getRawOffset() {
  223. +                    return 0;
  224. +                }
  225. +
  226. +                boolean inDaylightTime(Date time) {
  227. +                    return false;
  228. +                }
  229. +
  230. +                @Override
  231. +                public boolean useDaylightTime() {
  232. +                    return false;
  233. +                }
  234. +            };
  235. +            tz.ID = tzone;
  236. +            return tz;
  237.          }
  238. -        // TODO
  239. -        return getDefault();
  240. +        TimeZone tz = new TimeZone() {
  241. +            @Override
  242. +            public int getOffset(int era, int year, int month, int day, int dayOfWeek, int timeOfDayMillis) {
  243. +                return getTimezoneOffset(tzone, year, month + 1, day, timeOfDayMillis);
  244. +            }
  245. +
  246. +            @Override
  247. +            public int getRawOffset() {
  248. +                return getTimezoneRawOffset(tzone);
  249. +            }
  250. +
  251. +            boolean inDaylightTime(Date time) {
  252. +                return isTimezoneDST(tzone, time.getTime());
  253. +            }
  254. +
  255. +            @Override
  256. +            public boolean useDaylightTime() {
  257. +                return true;
  258. +            }
  259. +        };
  260. +        tz.ID = tzone;
  261. +        return tz;
  262.      }
  263.  
  264.      /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement