Commit 93f7aeea by Tom Tromey Committed by Tom Tromey

natString.cc (init): Handle case where DONT_COPY is true and OFFSET!=0.

	* java/lang/natString.cc (init): Handle case where DONT_COPY is
	true and OFFSET!=0.
	* java/lang/String.java (String(char[],int,int,boolean): New
	constructor.
	* java/lang/Long.java: Imported new version from Classpath.
	* java/lang/Number.java: Likewise.
	* java/lang/Integer.java: Likewise.
	* java/lang/Long.java: Likewise.
	* java/lang/Float.java: Likewise.
	* java/lang/Boolean.java: Likewise.
	* java/lang/Double.java: Likewise.
	* java/lang/Void.java: Likewise.

From-SVN: r54595
parent a8fa30f3
2002-06-13 Tom Tromey <tromey@redhat.com>
* java/lang/natString.cc (init): Handle case where DONT_COPY is
true and OFFSET!=0.
* java/lang/String.java (String(char[],int,int,boolean): New
constructor.
* java/lang/Long.java: Imported new version from Classpath.
* java/lang/Number.java: Likewise.
* java/lang/Integer.java: Likewise.
* java/lang/Long.java: Likewise.
* java/lang/Float.java: Likewise.
* java/lang/Boolean.java: Likewise.
* java/lang/Double.java: Likewise.
* java/lang/Void.java: Likewise.
2002-06-12 Tom Tromey <tromey@redhat.com>
* java/io/natFilePosix.cc (getCanonicalPath): Treat "" like ".".
......
/* Boolean.java -- object wrapper for boolean
Copyright (C) 1998, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -45,11 +45,16 @@ import java.io.Serializable;
* <code>boolean</code> values.
*
* @author Paul Fisher
* @since JDK1.0
* @author Eric Blake <ebb9@email.byu.edu>
* @since 1.0
* @status updated to 1.4
*/
public final class Boolean implements Serializable
{
static final long serialVersionUID = -3665804199014368530L;
/**
* Compatible with JDK 1.0.2+.
*/
private static final long serialVersionUID = -3665804199014368530L;
/**
* This field is a <code>Boolean</code> object representing the
......@@ -70,11 +75,14 @@ public final class Boolean implements Serializable
/**
* The primitive type <code>boolean</code> is represented by this
* <code>Class</code> object.
*
* @since 1.1
*/
public static final Class TYPE = VMClassLoader.getPrimitiveClass('Z');
/**
* The immutable value of this Boolean.
* @serial the wrapped value
*/
private final boolean value;
......@@ -85,8 +93,10 @@ public final class Boolean implements Serializable
* not create a new object.
*
* @param value the primitive value of this <code>Boolean</code>
* @see #valueOf(boolean)
*/
public Boolean(boolean value) {
public Boolean(boolean value)
{
this.value = value;
}
......@@ -101,15 +111,19 @@ public final class Boolean implements Serializable
* @param s the <code>String</code> representation of <code>true</code>
* or false
*/
public Boolean(String s) {
public Boolean(String s)
{
value = "true".equalsIgnoreCase(s);
}
/**
* Return the primitive <code>boolean</code> value of this
* <code>Boolean</code> object.
*
* @return true or false, depending on the value of this Boolean
*/
public boolean booleanValue() {
public boolean booleanValue()
{
return value;
}
......@@ -118,9 +132,14 @@ public final class Boolean implements Serializable
* <code>true</code>, otherwise it will return the Boolean
* <code>FALSE</code>.
*
* @param b the boolean to wrap
* @return the wrapper object
* @see #TRUE
* @see #FALSE
* @since 1.4
*/
public static Boolean valueOf(boolean b) {
public static Boolean valueOf(boolean b)
{
return b ? TRUE : FALSE;
}
......@@ -128,18 +147,49 @@ public final class Boolean implements Serializable
* Returns the Boolean <code>TRUE</code> if and only if the given
* String is equal, ignoring case, to the the String "true", otherwise
* it will return the Boolean <code>FALSE</code>.
*
* @param s the string to convert
* @return a wrapped boolean from the string
*/
public static Boolean valueOf(String s) {
public static Boolean valueOf(String s)
{
return "true".equalsIgnoreCase(s) ? TRUE : FALSE;
}
/**
* Returns "true" if the value of the give boolean is <code>true</code> and
* returns "false" if the value of the given boolean is <code>false</code>.
*
* @param b the boolean to convert
* @return the string representation of the boolean
* @since 1.4
*/
public static String toString(boolean b)
{
return b ? "true" : "false";
}
/**
* Returns "true" if the value of this object is <code>true</code> and
* returns "false" if the value of this object is <code>false</code>.
*
* @return the string representation of this
*/
public String toString()
{
return value ? "true" : "false";
}
/**
* Returns the integer <code>1231</code> if this object represents
* the primitive <code>true</code> and the integer <code>1237</code>
* otherwise.
*
* @return the hash code
*/
public int hashCode() {
return (value) ? 1231 : 1237;
public int hashCode()
{
return value ? 1231 : 1237;
}
/**
......@@ -149,40 +199,26 @@ public final class Boolean implements Serializable
* is <code>null</code>, <code>false</code> is returned.
*
* @param obj possibly an instance of any <code>Class</code>
* @return <code>false</code> is <code>obj</code> is an instance of
* <code>Boolean</code> and has the same primitive value as this
* object.
* @return true if <code>obj</code> equals this
*/
public boolean equals(Object obj) {
return (obj instanceof Boolean && value == ((Boolean)obj).value);
public boolean equals(Object obj)
{
return obj instanceof Boolean && value == ((Boolean) obj).value;
}
/**
* If the value of the system property <code>name</code> matches
* "true" ignoring case then the function returns <code>true</code>.
*/
public static boolean getBoolean(String name) {
String val = System.getProperty(name);
return ("true".equalsIgnoreCase(val));
}
/**
* Returns "true" if the value of the give boolean is <code>true</code> and
* returns "false" if the value of the given boolean is <code>false</code>.
*
* @since 1.4
*/
public static String toString(boolean b)
{
return b ? "true" : "false";
}
/**
* Returns "true" if the value of this object is <code>true</code> and
* returns "false" if the value of this object is <code>false</code>.
* @param name the property name to look up
* @return true if the property resulted in "true"
* @throws SecurityException if accessing the system property is forbidden
* @see System#getProperty(String)
*/
public String toString()
public static boolean getBoolean(String name)
{
return (value) ? "true" : "false";
if (name == null || "".equals(name))
return false;
return "true".equalsIgnoreCase(System.getProperty(name));
}
}
/* java.lang.Number
Copyright (C) 1998, 2001 Free Software Foundation, Inc.
/* Number.java =- abstract superclass of numeric objects
Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -41,54 +41,91 @@ package java.lang;
import java.io.Serializable;
/**
** Number is a generic superclass of all the numeric classes, namely
** <code>Byte</code>, <code>Short</code>, <code>Integer</code>,
** <code>Long</code>, <code>Float</code>, and <code>Double</code>.
**
** It provides ways to convert from any one value to any other.
**
** @author Paul Fisher
** @author John Keiser
** @author Warren Levy
** @since JDK1.0
**/
* Number is a generic superclass of all the numeric classes, including
* the wrapper classes {@link Byte}, {@link Short}, {@link Integer},
* {@link Long}, {@link Float}, and {@link Double}. Also worth mentioning
* are the classes in {@link java.math}.
*
* It provides ways to convert numeric objects to any primitive.
*
* @author Paul Fisher
* @author John Keiser
* @author Warren Levy
* @author Eric Blake <ebb9@email.byu.edu>
* @since 1.0
* @status updated to 1.4
*/
public abstract class Number implements Serializable
{
/** Return the value of this <code>Number</code> as a <code>byte</code>.
** @return the value of this <code>Number</code> as a <code>byte</code>.
**/
public byte byteValue()
{
return (byte) intValue();
}
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -8742448824652078965L;
/** Return the value of this <code>Number</code> as a <code>short</code>.
** @return the value of this <code>Number</code> as a <code>short</code>.
**/
public short shortValue()
/**
* Table for calculating digits, used in Character, Long, and Integer.
*/
static final char[] digits = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'
};
/**
* The basic constructor (often called implicitly).
*/
public Number()
{
return (short) intValue();
}
/** Return the value of this <code>Number</code> as an <code>int</code>.
** @return the value of this <code>Number</code> as an <code>int</code>.
**/
/**
* Return the value of this <code>Number</code> as an <code>int</code>.
*
* @return the int value
*/
public abstract int intValue();
/** Return the value of this <code>Number</code> as a <code>long</code>.
** @return the value of this <code>Number</code> as a <code>long</code>.
**/
/**
* Return the value of this <code>Number</code> as a <code>long</code>.
*
* @return the long value
*/
public abstract long longValue();
/** Return the value of this <code>Number</code> as a <code>float</code>.
** @return the value of this <code>Number</code> as a <code>float</code>.
**/
/**
* Return the value of this <code>Number</code> as a <code>float</code>.
*
* @return the float value
*/
public abstract float floatValue();
/** Return the value of this <code>Number</code> as a <code>float</code>.
** @return the value of this <code>Number</code> as a <code>float</code>.
**/
/**
* Return the value of this <code>Number</code> as a <code>float</code>.
*
* @return the double value
*/
public abstract double doubleValue();
private static final long serialVersionUID = -8742448824652078965L;
/**
* Return the value of this <code>Number</code> as a <code>byte</code>.
*
* @return the byte value
* @since 1.1
*/
public byte byteValue()
{
return (byte) intValue();
}
/**
* Return the value of this <code>Number</code> as a <code>short</code>.
*
* @return the short value
* @since 1.1
*/
public short shortValue()
{
return (short) intValue();
}
}
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj.
......@@ -112,6 +112,12 @@ public final class String implements Serializable, Comparable, CharSequence
init(data, offset, count, false);
}
// This is used by Integer.toString(int,int).
String (char[] data, int offset, int count, boolean dont_copy)
{
init(data, offset, count, dont_copy);
}
public String (byte[] byteArray)
{
this (byteArray, 0, byteArray.length);
......
/* java.lang.Void
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
/* Void.class - defines void.class
Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -38,19 +38,18 @@ exception statement from your version. */
package java.lang;
/* Written using "Java Class Libraries", 2nd edition, plus online
* API docs for JDK 1.2 beta from http://www.javasoft.com.
* Status: Complete.
*/
/**
* Void is a placeholder class so that the variable Void.TYPE can be
* supported for reflection return types.
* Void is a placeholder class so that the variable <code>Void.TYPE</code>
* (also available as <code>void.class</code>) can be supported for
* reflection return types.
*
* <p>This class could be Serializable, but that is up to Sun.
*
* @author Paul Fisher
* @author John Keiser
* @author Per Bothner <bothner@cygnus.com>
* @since JDK1.1
* @author Eric Blake <ebb9@email.byu.edu>
* @since 1.1
* @status updated to 1.4
*/
public final class Void
{
......@@ -61,7 +60,7 @@ public final class Void
public static final Class TYPE = VMClassLoader.getPrimitiveClass('V');
/**
* Don't allow Void objects to be made.
* Void is non-instantiable.
*/
private Void() { }
}
......@@ -456,9 +456,8 @@ java::lang::String::init(jcharArray chars, jint offset, jint count,
}
else
{
JvAssert (offset == 0);
array = chars;
pdst = elements (array);
pdst = &(elements(array)[offset]);
}
data = array;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment