summaryrefslogtreecommitdiff
path: root/libjava/classpath/vm
diff options
context:
space:
mode:
authordoko <doko@138bc75d-0d04-0410-961f-82ee72b054a4>2008-06-28 13:29:13 +0000
committerdoko <doko@138bc75d-0d04-0410-961f-82ee72b054a4>2008-06-28 13:29:13 +0000
commit1020ce5944edde4364baef4d371cd4f9b0dae721 (patch)
tree602cd7aa7c947386134690d8e0f6b53abcdeacb9 /libjava/classpath/vm
parent9f41ce98ce6f4f7c8ac5e2c4b6e5d27e10201015 (diff)
downloadgcc-1020ce5944edde4364baef4d371cd4f9b0dae721.tar.gz
libjava/
2008-06-28 Matthias Klose <doko@ubuntu.com> Import GNU Classpath (classpath-0_97_2-release). * Regenerate class and header files. * Regenerate auto* files. * gcj/javaprims.h: Define jobjectRefType. * jni.cc (_Jv_JNI_GetObjectRefType): New (stub only). (_Jv_JNIFunctions): Initialize GetObjectRefType. * gnu/classpath/jdwp/VMVirtualMachine.java, java/security/VMSecureRandom.java: Merge from classpath. * HACKING: Fix typo. * ChangeLog-2007: New file. * configure.ac: Set JAVAC, pass --disable-regen-headers to classpath. libjava/classpath/ 2008-06-28 Matthias Klose <doko@ubuntu.com> * m4/ac_prog_javac.m4: Disable check for JAVAC, when not configured with --enable-java-maintainer-mode. * aclocal.m4, configure: Regenerate. * native/jni/gstreamer-peer/Makefile.am: Do not link with libclasspathnative. * native/jni/gstreamer-peer/Makefile.in: Regenerate. * tools/Makefile.am, lib/Makefile.am: Use JAVAC for setting JCOMPILER, drop flags not understood by gcj. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137223 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/vm')
-rw-r--r--libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java1
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java57
-rw-r--r--libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java1
-rw-r--r--libjava/classpath/vm/reference/java/io/VMFile.java19
-rw-r--r--libjava/classpath/vm/reference/java/lang/VMClass.java25
-rw-r--r--libjava/classpath/vm/reference/java/lang/VMDouble.java16
-rw-r--r--libjava/classpath/vm/reference/java/lang/VMFloat.java15
-rw-r--r--libjava/classpath/vm/reference/java/lang/reflect/Constructor.java24
-rw-r--r--libjava/classpath/vm/reference/java/lang/reflect/Method.java24
-rw-r--r--libjava/classpath/vm/reference/java/security/VMSecureRandom.java5
10 files changed, 137 insertions, 50 deletions
diff --git a/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java b/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java
index 3556220ae8a..639a957194b 100644
--- a/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java
+++ b/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java
@@ -48,7 +48,6 @@ import gnu.classpath.jdwp.util.MethodResult;
import gnu.classpath.jdwp.util.MonitorInfo;
import gnu.classpath.jdwp.value.Value;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
index 43b9ae1a100..eade26374db 100644
--- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
@@ -37,8 +37,14 @@ exception statement from your version. */
package gnu.java.lang.management;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryPoolMXBean;
+import java.lang.management.MemoryType;
import java.lang.management.MemoryUsage;
+import java.util.Iterator;
+import java.util.List;
+
/**
* Provides access to information about the memory
* management of the current invocation of the virtual
@@ -62,10 +68,7 @@ final class VMMemoryMXBeanImpl
*/
static MemoryUsage getHeapMemoryUsage()
{
- Runtime runtime = Runtime.getRuntime();
- long totalMem = runtime.totalMemory();
- return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
- totalMem, runtime.maxMemory());
+ return getUsage(MemoryType.HEAP);
}
/**
@@ -76,7 +79,10 @@ final class VMMemoryMXBeanImpl
* @return an {@link java.lang.management.MemoryUsage} instance
* for non-heap memory.
*/
- static native MemoryUsage getNonHeapMemoryUsage();
+ static MemoryUsage getNonHeapMemoryUsage()
+ {
+ return getUsage(MemoryType.NON_HEAP);
+ }
/**
* Returns the number of objects ready to be garbage collected.
@@ -106,4 +112,45 @@ final class VMMemoryMXBeanImpl
*/
static native void setVerbose(boolean verbose);
+ /**
+ * Totals the memory usage from all the pools that match
+ * the given type.
+ *
+ * @param type the type of memory pools to accumulate
+ * (heap or non-heap).
+ * @return the memory usage overall.
+ */
+ private static MemoryUsage getUsage(MemoryType type) {
+ long init = 0, committed = 0, used = 0, max = 0;
+ Iterator pools =
+ ManagementFactory.getMemoryPoolMXBeans().iterator();
+ while (pools.hasNext())
+ {
+ MemoryPoolMXBean pool = (MemoryPoolMXBean) pools.next();
+ if (pool.getType() == type)
+ {
+ MemoryUsage usage = pool.getUsage();
+ if (init != -1)
+ {
+ long poolInit = usage.getInit();
+ if (poolInit == -1)
+ init = -1;
+ else
+ init += poolInit;
+ }
+ committed += usage.getCommitted();
+ used += usage.getUsed();
+ if (max != -1)
+ {
+ long poolMax = usage.getMax();
+ if (poolMax == -1)
+ max = -1;
+ else
+ max += poolMax;
+ }
+ }
+ }
+ return new MemoryUsage(init, used, committed, max);
+ }
+
}
diff --git a/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java b/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java
index 1f69877b6ba..a9d1452b72d 100644
--- a/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java
+++ b/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java
@@ -256,7 +256,6 @@ public final class VMChannel
* Assumes the that buffer list constains DirectBuffers. Will perform
* as gathering write.
*
- * @param fd
* @param srcs
* @param offset
* @param length
diff --git a/libjava/classpath/vm/reference/java/io/VMFile.java b/libjava/classpath/vm/reference/java/io/VMFile.java
index 4f708a4a589..2a2751765ec 100644
--- a/libjava/classpath/vm/reference/java/io/VMFile.java
+++ b/libjava/classpath/vm/reference/java/io/VMFile.java
@@ -80,10 +80,10 @@ final class VMFile
static native boolean create(String path) throws IOException;
/*
- * This native function actually produces the list of file in this
+ * This native function actually produces the list of files in this
* directory
*/
- static native String[] list(String dirpath);
+ static native synchronized String[] list(String dirpath);
/*
* This native method actually performs the rename.
@@ -117,6 +117,21 @@ final class VMFile
static native boolean mkdir(String dirpath);
/**
+ * Gets the total bytes of the filesystem named by path.
+ */
+ public static native long getTotalSpace(String path);
+
+ /**
+ * Gets the total free bytes of the filesystem named by path.
+ */
+ public static native long getFreeSpace(String path);
+
+ /**
+ * Gets the available bytes of the filesystem named by path.
+ */
+ public static native long getUsableSpace(String path);
+
+ /**
* Set the read permission of the file.
*/
public static synchronized native boolean setReadable(String path,
diff --git a/libjava/classpath/vm/reference/java/lang/VMClass.java b/libjava/classpath/vm/reference/java/lang/VMClass.java
index 25965068daf..7e9620b4b59 100644
--- a/libjava/classpath/vm/reference/java/lang/VMClass.java
+++ b/libjava/classpath/vm/reference/java/lang/VMClass.java
@@ -43,8 +43,6 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
/*
* This class is a reference version, mainly for compiling a class library
@@ -298,12 +296,27 @@ final class VMClass
*/
static String getSimpleName(Class klass)
{
+ if (isAnonymousClass(klass))
+ return "";
if (isArray(klass))
{
return getComponentType(klass).getSimpleName() + "[]";
}
String fullName = getName(klass);
- return fullName.substring(fullName.lastIndexOf(".") + 1);
+ int pos = fullName.lastIndexOf("$");
+ if (pos == -1)
+ pos = 0;
+ else
+ {
+ ++pos;
+ while (Character.isDigit(fullName.charAt(pos)))
+ ++pos;
+ }
+ int packagePos = fullName.lastIndexOf(".", pos);
+ if (packagePos == -1)
+ return fullName.substring(pos);
+ else
+ return fullName.substring(packagePos + 1);
}
/**
@@ -357,6 +370,8 @@ final class VMClass
*/
static String getCanonicalName(Class klass)
{
+ if (isLocalClass(klass) || isAnonymousClass(klass))
+ return null;
if (isArray(klass))
{
String componentName = getComponentType(klass).getCanonicalName();
@@ -368,9 +383,9 @@ final class VMClass
String memberName = getDeclaringClass(klass).getCanonicalName();
if (memberName != null)
return memberName + "." + getSimpleName(klass);
+ else
+ return memberName;
}
- if (isLocalClass(klass) || isAnonymousClass(klass))
- return null;
return getName(klass);
}
diff --git a/libjava/classpath/vm/reference/java/lang/VMDouble.java b/libjava/classpath/vm/reference/java/lang/VMDouble.java
index 8a991c9ad78..58b3b45b420 100644
--- a/libjava/classpath/vm/reference/java/lang/VMDouble.java
+++ b/libjava/classpath/vm/reference/java/lang/VMDouble.java
@@ -70,22 +70,6 @@ final class VMDouble
* layout. Bit 63 (the most significant) is the sign bit, bits 62-52
* (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
* (masked by 0x000fffffffffffffL) are the mantissa. This function
- * collapses all versions of NaN to 0x7ff8000000000000L. The result of this
- * function can be used as the argument to
- * <code>Double.longBitsToDouble(long)</code> to obtain the original
- * <code>double</code> value.
- *
- * @param value the <code>double</code> to convert
- * @return the bits of the <code>double</code>
- * @see #longBitsToDouble(long)
- */
- public static native long doubleToLongBits(double value);
-
- /**
- * Convert the double to the IEEE 754 floating-point "double format" bit
- * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
- * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
- * (masked by 0x000fffffffffffffL) are the mantissa. This function
* leaves NaN alone, rather than collapsing to a canonical value. The
* result of this function can be used as the argument to
* <code>Double.longBitsToDouble(long)</code> to obtain the original
diff --git a/libjava/classpath/vm/reference/java/lang/VMFloat.java b/libjava/classpath/vm/reference/java/lang/VMFloat.java
index 15348130f10..26d89dc9d19 100644
--- a/libjava/classpath/vm/reference/java/lang/VMFloat.java
+++ b/libjava/classpath/vm/reference/java/lang/VMFloat.java
@@ -67,21 +67,6 @@ final class VMFloat
* Convert the float to the IEEE 754 floating-point "single format" bit
* layout. Bit 31 (the most significant) is the sign bit, bits 30-23
* (masked by 0x7f800000) represent the exponent, and bits 22-0
- * (masked by 0x007fffff) are the mantissa. This function collapses all
- * versions of NaN to 0x7fc00000. The result of this function can be used
- * as the argument to <code>Float.intBitsToFloat(int)</code> to obtain the
- * original <code>float</code> value.
- *
- * @param value the <code>float</code> to convert
- * @return the bits of the <code>float</code>
- * @see #intBitsToFloat(int)
- */
- static native int floatToIntBits(float value);
-
- /**
- * Convert the float to the IEEE 754 floating-point "single format" bit
- * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
- * (masked by 0x7f800000) represent the exponent, and bits 22-0
* (masked by 0x007fffff) are the mantissa. This function leaves NaN alone,
* rather than collapsing to a canonical value. The result of this function
* can be used as the argument to <code>Float.intBitsToFloat(int)</code> to
diff --git a/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java b/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java
index eebee5f5d2a..8c604ccc9a6 100644
--- a/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java
+++ b/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java
@@ -42,6 +42,7 @@ import gnu.java.lang.ClassHelper;
import gnu.java.lang.reflect.MethodSignatureParser;
+import java.lang.annotation.Annotation;
import java.util.Arrays;
/**
@@ -393,4 +394,27 @@ public final class Constructor<T>
MethodSignatureParser p = new MethodSignatureParser(this, sig);
return p.getGenericParameterTypes();
}
+
+ /**
+ * <p>
+ * Return an array of arrays representing the annotations on each
+ * of the constructor's parameters. The outer array is aligned against
+ * the parameters of the constructors and is thus equal in length to
+ * the number of parameters (thus having a length zero if there are none).
+ * Each array element in the outer array contains an inner array which
+ * holds the annotations. This array has a length of zero if the parameter
+ * has no annotations.
+ * </p>
+ * <p>
+ * The returned annotations are serialized. Changing the annotations has
+ * no affect on the return value of future calls to this method.
+ * </p>
+ *
+ * @return an array of arrays which represents the annotations used on the
+ * parameters of this constructor. The order of the array elements
+ * matches the declaration order of the parameters.
+ * @since 1.5
+ */
+ public native Annotation[][] getParameterAnnotations();
+
}
diff --git a/libjava/classpath/vm/reference/java/lang/reflect/Method.java b/libjava/classpath/vm/reference/java/lang/reflect/Method.java
index 2db59fee46f..d797d4fda18 100644
--- a/libjava/classpath/vm/reference/java/lang/reflect/Method.java
+++ b/libjava/classpath/vm/reference/java/lang/reflect/Method.java
@@ -42,6 +42,7 @@ import gnu.java.lang.ClassHelper;
import gnu.java.lang.reflect.MethodSignatureParser;
+import java.lang.annotation.Annotation;
import java.util.Arrays;
/**
@@ -462,4 +463,27 @@ extends AccessibleObject implements Member, GenericDeclaration
* @since 1.5
*/
public native Object getDefaultValue();
+
+ /**
+ * <p>
+ * Return an array of arrays representing the annotations on each
+ * of the method's parameters. The outer array is aligned against
+ * the parameters of the method and is thus equal in length to
+ * the number of parameters (thus having a length zero if there are none).
+ * Each array element in the outer array contains an inner array which
+ * holds the annotations. This array has a length of zero if the parameter
+ * has no annotations.
+ * </p>
+ * <p>
+ * The returned annotations are serialized. Changing the annotations has
+ * no affect on the return value of future calls to this method.
+ * </p>
+ *
+ * @return an array of arrays which represents the annotations used on the
+ * parameters of this method. The order of the array elements
+ * matches the declaration order of the parameters.
+ * @since 1.5
+ */
+ public native Annotation[][] getParameterAnnotations();
+
}
diff --git a/libjava/classpath/vm/reference/java/security/VMSecureRandom.java b/libjava/classpath/vm/reference/java/security/VMSecureRandom.java
index dc67d871968..5eeb158bc81 100644
--- a/libjava/classpath/vm/reference/java/security/VMSecureRandom.java
+++ b/libjava/classpath/vm/reference/java/security/VMSecureRandom.java
@@ -38,11 +38,6 @@ exception statement from your version. */
package java.security;
-import gnu.classpath.SystemProperties;
-import gnu.java.security.action.GetSecurityPropertyAction;
-
-import java.net.URL;
-
/**
* VM-specific methods for generating real (or almost real) random
* seeds. VM implementors should write a version of this class that