Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/vm/JavaAPI/src/java/lang/Byte.java b/vm/JavaAPI/src/java/lang/Byte.java
- index 2547124..3713a5e 100644
- --- a/vm/JavaAPI/src/java/lang/Byte.java
- +++ b/vm/JavaAPI/src/java/lang/Byte.java
- @@ -38,6 +38,7 @@ public final class Byte{
- * See Also:Constant Field Values
- */
- public static final byte MIN_VALUE = -128;
- + public static final int SIZE = 8;
- private byte value;
- diff --git a/vm/JavaAPI/src/java/lang/Integer.java b/vm/JavaAPI/src/java/lang/Integer.java
- index c833a87..9812077 100644
- --- a/vm/JavaAPI/src/java/lang/Integer.java
- +++ b/vm/JavaAPI/src/java/lang/Integer.java
- @@ -46,6 +46,7 @@ public final class Integer{
- * See Also:Constant Field Values
- */
- public static final int MIN_VALUE=-2147483648;
- + public static final int SIZE=32;
- private int value;
- @@ -199,7 +200,7 @@ public final class Integer{
- } while ((i >>>= 1) != 0);
- //return new String(cursor, bufLen - cursor, buf);
- - return new String(cursor, bufLen - cursor, buf);
- + return new String(buf, cursor, bufLen - cursor);
- }
- @@ -226,7 +227,7 @@ public final class Integer{
- buf[--cursor] = digits[i & 0xf];
- } while ((i >>>= 4) != 0 || (bufLen - cursor < minWidth));
- - return new String(cursor, bufLen - cursor, buf);
- + return new String(buf, cursor, bufLen - cursor);
- }
- public static String intToOctalString(int i) {
- @@ -238,7 +239,7 @@ public final class Integer{
- buf[--cursor] = DIGITS[i & 7];
- } while ((i >>>= 3) != 0);
- - return new String(cursor, bufLen - cursor, buf);
- + return new String(buf, cursor, bufLen - cursor);
- }
- /**
- @@ -322,4 +323,9 @@ public final class Integer{
- public static int signum(int i) {
- return (i >> 31) | (-i >>> 31); // Hacker's delight 2-7
- }
- +
- + public static int compare(int x, int y) {
- + return (x < y) ? -1 : ((x == y) ? 0 : 1);
- + }
- +
- }
- diff --git a/vm/JavaAPI/src/java/lang/Math.java b/vm/JavaAPI/src/java/lang/Math.java
- index aac4fd8..a80db95 100644
- --- a/vm/JavaAPI/src/java/lang/Math.java
- +++ b/vm/JavaAPI/src/java/lang/Math.java
- @@ -201,5 +201,14 @@ public final class Math{
- }
- return (int) floor(f + 0.5f);
- }
- +
- + public static double signum(double d) {
- + return (d == 0.0 ? 0 : (d < 0 ? -1 : 1));
- + }
- +
- + public static float signum(float d) {
- + return (d == 0.0 ? 0 : (d < 0 ? -1 : 1));
- + }
- +
- }
- diff --git a/vm/JavaAPI/src/java/lang/String.java b/vm/JavaAPI/src/java/lang/String.java
- index 38078f8..ae3b7db 100644
- --- a/vm/JavaAPI/src/java/lang/String.java
- +++ b/vm/JavaAPI/src/java/lang/String.java
- @@ -198,6 +198,9 @@ public final class String implements java.lang.CharSequence, Comparable<String>
- System.arraycopy(str.value, str.offset, n, count, str.count);
- return new String(n);
- }
- + public boolean contains(java.lang.CharSequence instr){
- + return indexOf(instr.toString()) >= 0;
- + }
- /**
- * Tests if this string ends with the specified suffix.
- @@ -823,6 +826,10 @@ public final class String implements java.lang.CharSequence, Comparable<String>
- return Long.toString(l);
- }
- + public boolean isEmpty() {
- + return value.length == 0;
- + }
- +
- /**
- * Returns the string representation of the Object argument.
- */
- diff --git a/vm/JavaAPI/src/java/lang/System.java b/vm/JavaAPI/src/java/lang/System.java
- index 1dc144a..e91c294 100644
- --- a/vm/JavaAPI/src/java/lang/System.java
- +++ b/vm/JavaAPI/src/java/lang/System.java
- @@ -136,7 +136,6 @@ public final class System {
- public static void gc() {
- if(startedGc) {
- forceGc = true;
- - gcShouldLoop = true;
- }
- startGCThread();
- synchronized(LOCK) {
- diff --git a/vm/JavaAPI/src/java/lang/Throwable.java b/vm/JavaAPI/src/java/lang/Throwable.java
- index d911a16..10f0858 100644
- --- a/vm/JavaAPI/src/java/lang/Throwable.java
- +++ b/vm/JavaAPI/src/java/lang/Throwable.java
- @@ -80,6 +80,10 @@ public class Throwable{
- System.out.println(stack);
- }
- + public void printStackTrace(java.io.PrintStream stream){
- + stream.println(stack);
- + }
- +
- /**
- * Returns a short description of this Throwable object. If this Throwable object was
- * 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
- diff --git a/vm/JavaAPI/src/java/util/Random.java b/vm/JavaAPI/src/java/util/Random.java
- index 6ace608..5edc4dd 100644
- --- a/vm/JavaAPI/src/java/util/Random.java
- +++ b/vm/JavaAPI/src/java/util/Random.java
- @@ -123,4 +123,15 @@ public class Random{
- this.seed = (seed ^ multiplier) & ((1L << 48) - 1);
- }
- + public void nextBytes(byte[] bytes) {
- + for (int i = 0, len = bytes.length; i < len; )
- + for (int rnd = nextInt(),
- + n = Math.min(len - i, Integer.SIZE/Byte.SIZE);
- + n-- > 0; rnd >>= Byte.SIZE)
- + bytes[i++] = (byte)rnd;
- + }
- +
- +
- +
- +
- }
- diff --git a/vm/JavaAPI/src/java/util/TimeZone.java b/vm/JavaAPI/src/java/util/TimeZone.java
- index 0b0e376..1e2fb99 100644
- --- a/vm/JavaAPI/src/java/util/TimeZone.java
- +++ b/vm/JavaAPI/src/java/util/TimeZone.java
- @@ -31,26 +31,26 @@ public abstract class TimeZone{
- * style may yield GMT offsets like {@code GMT-08:00}.
- */
- public static final int SHORT = 0;
- -
- +
- /**
- * The long display name style, such as {@code Pacific Daylight Time}.
- * Requests for this style may yield GMT offsets like {@code GMT-08:00}.
- */
- public static final int LONG = 1;
- -
- +
- static final TimeZone GMT = new SimpleTimeZone(0, "GMT"); // Greenwich Mean Time
- -
- +
- private static TimeZone defaultTimeZone;
- -
- +
- private String ID;
- - public TimeZone(){
- + public TimeZone(){
- }
- void setID(String id) {
- ID = id;
- }
- -
- +
- /**
- * Gets all the available IDs supported.
- */
- @@ -102,12 +102,12 @@ public abstract class TimeZone{
- int getDSTSavings() {
- return useDaylightTime() ? 3600000 : 0;
- }
- -
- -
- +
- +
- boolean inDaylightTime(Date time) {
- return false;
- }
- -
- +
- /**
- * Gets the ID of this time zone.
- */
- @@ -128,12 +128,53 @@ public abstract class TimeZone{
- /**
- * Gets the TimeZone for the given ID.
- */
- - public static java.util.TimeZone getTimeZone(java.lang.String ID){
- - if(ID != null && ID.equalsIgnoreCase("gmt")) {
- - return GMT;
- + public static java.util.TimeZone getTimeZone(final java.lang.String tzone){
- + if ("UTC".equals(tzone)) {
- + TimeZone tz = new TimeZone() {
- + @Override
- + public int getOffset(int era, int year, int month, int day, int dayOfWeek, int timeOfDayMillis) {
- + return 0;
- + }
- +
- + @Override
- + public int getRawOffset() {
- + return 0;
- + }
- +
- + boolean inDaylightTime(Date time) {
- + return false;
- + }
- +
- + @Override
- + public boolean useDaylightTime() {
- + return false;
- + }
- + };
- + tz.ID = tzone;
- + return tz;
- }
- - // TODO
- - return getDefault();
- + TimeZone tz = new TimeZone() {
- + @Override
- + public int getOffset(int era, int year, int month, int day, int dayOfWeek, int timeOfDayMillis) {
- + return getTimezoneOffset(tzone, year, month + 1, day, timeOfDayMillis);
- + }
- +
- + @Override
- + public int getRawOffset() {
- + return getTimezoneRawOffset(tzone);
- + }
- +
- + boolean inDaylightTime(Date time) {
- + return isTimezoneDST(tzone, time.getTime());
- + }
- +
- + @Override
- + public boolean useDaylightTime() {
- + return true;
- + }
- + };
- + tz.ID = tzone;
- + return tz;
- }
- /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement