You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/10/31 09:42:35 UTC
svn commit: r590591 [3/12] - in /harmony/enhanced/classlib/branches/java6:
depends/build/platform/ depends/files/ depends/jars/icu4j_3.8/
depends/libs/freebsd.x86/ depends/manifests/icu4j_3.4.4/
depends/manifests/icu4j_3.8/ depends/manifests/icu4j_3.8/...
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java Wed Oct 31 01:42:07 2007
@@ -45,10 +45,11 @@
* @see java.lang.Comparable
*/
public class File implements Serializable, Comparable<File> {
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final long serialVersionUID = 301077366599181567L;
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
private String path;
transient byte[] properPath;
@@ -168,7 +169,7 @@
private String calculatePath(String dirPath, String name) {
dirPath = fixSlashes(dirPath);
- if (!name.equals(EMPTY_STRING) || dirPath.equals(EMPTY_STRING)) {
+ if (!name.equals(EMPTY_STRING) || dirPath.equals(EMPTY_STRING)) {
// Remove all the proceeding separator chars from name
name = fixSlashes(name);
@@ -192,36 +193,37 @@
return dirPath;
}
+ @SuppressWarnings("nls")
private void checkURI(URI uri) {
if (!uri.isAbsolute()) {
- throw new IllegalArgumentException(Msg.getString("K031a", uri)); //$NON-NLS-1$
- } else if (!uri.getRawSchemeSpecificPart().startsWith("/")) { //$NON-NLS-1$
- throw new IllegalArgumentException(Msg.getString("K031b", uri)); //$NON-NLS-1$
+ throw new IllegalArgumentException(Msg.getString("K031a", uri));
+ } else if (!uri.getRawSchemeSpecificPart().startsWith("/")) {
+ throw new IllegalArgumentException(Msg.getString("K031b", uri));
}
String temp = uri.getScheme();
- if (temp == null || !temp.equals("file")) { //$NON-NLS-1$
- throw new IllegalArgumentException(Msg.getString("K031c", uri)); //$NON-NLS-1$
+ if (temp == null || !temp.equals("file")) {
+ throw new IllegalArgumentException(Msg.getString("K031c", uri));
}
temp = uri.getRawPath();
if (temp == null || temp.length() == 0) {
- throw new IllegalArgumentException(Msg.getString("K031d", uri)); //$NON-NLS-1$
+ throw new IllegalArgumentException(Msg.getString("K031d", uri));
}
if (uri.getRawAuthority() != null) {
- throw new IllegalArgumentException(Msg.getString(
- "K031e", new String[] { "authority", uri.toString() })); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException(Msg.getString("K031e",
+ new String[] { "authority", uri.toString() }));
}
if (uri.getRawQuery() != null) {
- throw new IllegalArgumentException(Msg.getString(
- "K031e", new String[] { "query", uri.toString() })); //$NON-NLS-1$//$NON-NLS-2$
+ throw new IllegalArgumentException(Msg.getString("K031e",
+ new String[] { "query", uri.toString() }));
}
if (uri.getRawFragment() != null) {
- throw new IllegalArgumentException(Msg.getString(
- "K031e", new String[] { "fragment", uri.toString() })); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException(Msg.getString("K031e",
+ new String[] { "fragment", uri.toString() }));
}
}
@@ -1018,7 +1020,7 @@
}
if (!isDirectory() || !canRead()) {
return null;
- }
+ }
byte[][] implList = listImpl(properPath(true));
if (implList == null) {
// empty list
@@ -1027,7 +1029,6 @@
String result[] = new String[implList.length];
for (int index = 0; index < implList.length; index++) {
result[index] = Util.toUTF8String(implList[index]);
- //result[index] = Util.toString(implList[index]);
}
return result;
}
@@ -1333,7 +1334,7 @@
if (properPath != null) {
return properPath;
}
- byte[] pathBytes = Util.getUTF8Bytes(path);
+ byte[] pathBytes = Util.getUTF8Bytes(path);
if (isAbsoluteImpl(pathBytes)) {
return properPath = pathBytes;
}
@@ -1352,19 +1353,18 @@
return properPath = Util.getUTF8Bytes(userdir);
}
int length = userdir.length();
-
+
// Handle windows-like path
if (path.charAt(0) == '\\') {
if (length > 1 && userdir.charAt(1) == ':') {
return properPath = Util.getUTF8Bytes(userdir.substring(0, 2)
+ path);
- } else {
- path = path.substring(1);
}
+ path = path.substring(1);
}
-
+
// Handle separator
- String result = userdir;
+ String result = userdir;
if (userdir.charAt(length - 1) != separatorChar) {
if (path.charAt(0) != separatorChar) {
result += separator;
@@ -1374,7 +1374,7 @@
}
result += path;
- return properPath = Util.getUTF8Bytes(result);
+ return properPath = Util.getUTF8Bytes(result);
}
private static native byte[] properPathImpl(byte[] path);
@@ -1421,18 +1421,19 @@
*
* @return a <code>file</code> URI for this File.
*/
+ @SuppressWarnings("nls")
public URI toURI() {
String name = getAbsoluteName();
try {
- if (!name.startsWith("/")) { //$NON-NLS-1$
+ if (!name.startsWith("/")) {
// start with sep.
- return new URI("file", null, //$NON-NLS-1$
- new StringBuilder(name.length() + 1).append('/')
- .append(name).toString(), null, null);
- } else if (name.startsWith("//")) { //$NON-NLS-1$
- return new URI("file", name, null); // UNC path //$NON-NLS-1$
+ return new URI("file", null, new StringBuilder(
+ name.length() + 1).append('/').append(name).toString(),
+ null, null);
+ } else if (name.startsWith("//")) {
+ return new URI("file", name, null); // UNC path
}
- return new URI("file", null, name, null, null); //$NON-NLS-1$
+ return new URI("file", null, name, null, null);
} catch (URISyntaxException e) {
// this should never happen
return null;
@@ -1451,16 +1452,18 @@
* @deprecated Use File.toURI() and URI.toURL() instead
*/
@Deprecated
+ @SuppressWarnings("nls")
public URL toURL() throws java.net.MalformedURLException {
String name = getAbsoluteName();
- if (!name.startsWith("/")) { //$NON-NLS-1$
+ if (!name.startsWith("/")) {
// start with sep.
- return new URL("file", EMPTY_STRING, -1, new StringBuilder(name.length() + 1) //$NON-NLS-1$
- .append('/').append(name).toString(), null);
- } else if (name.startsWith("//")) { //$NON-NLS-1$
- return new URL("file:" + name); // UNC path //$NON-NLS-1$
+ return new URL(
+ "file", EMPTY_STRING, -1, new StringBuilder(name.length() + 1) //$NON-NLS-1$
+ .append('/').append(name).toString(), null);
+ } else if (name.startsWith("//")) {
+ return new URL("file:" + name); // UNC path
}
- return new URL("file", EMPTY_STRING, -1, name, null); //$NON-NLS-1$
+ return new URL("file", EMPTY_STRING, -1, name, null);
}
private String getAbsoluteName() {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java Wed Oct 31 01:42:07 2007
@@ -31,6 +31,7 @@
import java.util.Iterator;
import org.apache.harmony.kernel.vm.VM;
+import org.apache.harmony.luni.internal.nls.Messages;
import org.apache.harmony.luni.util.Msg;
import org.apache.harmony.luni.util.PriviAction;
@@ -985,7 +986,7 @@
return classSig;
}
- while (classSig.startsWith("[L", start)
+ while (classSig.startsWith("[L", start) //$NON-NLS-1$
&& classSig.charAt(end - 1) == ';') {
start += 2;
end--;
@@ -1774,7 +1775,8 @@
ObjectStreamClass newClassDesc = new ObjectStreamClass();
String name = input.readUTF();
if (name.length() == 0) {
- throw new IOException("The stream is corrupted.");
+ // luni.07 = The stream is corrupted
+ throw new IOException(Messages.getString("luni.07")); //$NON-NLS-1$
}
newClassDesc.setName(name);
newClassDesc.setSerialVersionUID(input.readLong());
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java Wed Oct 31 01:42:07 2007
@@ -140,9 +140,13 @@
private static final WeakHashMap<Class<?>, ObjectStreamClass> classesAndDescriptors = new WeakHashMap<Class<?>, ObjectStreamClass>();
private transient Method methodWriteReplace;
+
private transient Method methodReadResolve;
+
private transient Method methodWriteObject;
+
private transient Method methodReadObject;
+
private transient Method methodReadObjectNoData;
// ClassDesc //
@@ -200,7 +204,8 @@
* a boolean indicating if SUID should be computed or not.
* @return the computer class descriptor
*/
- private static ObjectStreamClass createClassDesc(Class<?> cl, boolean computeSUID) {
+ private static ObjectStreamClass createClassDesc(Class<?> cl,
+ boolean computeSUID) {
ObjectStreamClass result = new ObjectStreamClass();
@@ -223,7 +228,8 @@
result.setSerialVersionUID(0L);
} else {
declaredFields = cl.getDeclaredFields();
- result.setSerialVersionUID(computeSerialVersionUID(cl, declaredFields));
+ result.setSerialVersionUID(computeSerialVersionUID(cl,
+ declaredFields));
}
}
@@ -242,7 +248,7 @@
// Copy all fields to loadFields - they should be read by default in
// ObjectInputStream.defaultReadObject() method
ObjectStreamField[] fields = result.getFields();
-
+
if (fields != null) {
ObjectStreamField[] loadFields = new ObjectStreamField[fields.length];
@@ -250,7 +256,8 @@
loadFields[i] = new ObjectStreamField(fields[i].getName(),
fields[i].getType(), fields[i].isUnshared());
- // resolve type string to init typeString field in ObjectStreamField
+ // resolve type string to init typeString field in
+ // ObjectStreamField
loadFields[i].getTypeString();
}
result.setLoadFields(loadFields);
@@ -263,16 +270,14 @@
} else if (serializable) {
flags |= ObjectStreamConstants.SC_SERIALIZABLE;
}
- result.methodWriteReplace =
- findMethod(cl, "writeReplace");
- result.methodReadResolve =
- findMethod(cl, "readResolve");
- result.methodWriteObject =
- findPrivateMethod(cl, "writeObject", WRITE_PARAM_TYPES);
- result.methodReadObject =
- findPrivateMethod(cl, "readObject", READ_PARAM_TYPES);
- result.methodReadObjectNoData =
- findPrivateMethod(cl, "readObjectNoData", EMPTY_CONSTRUCTOR_PARAM_TYPES);
+ result.methodWriteReplace = findMethod(cl, "writeReplace"); //$NON-NLS-1$
+ result.methodReadResolve = findMethod(cl, "readResolve"); //$NON-NLS-1$
+ result.methodWriteObject = findPrivateMethod(cl, "writeObject", //$NON-NLS-1$
+ WRITE_PARAM_TYPES);
+ result.methodReadObject = findPrivateMethod(cl, "readObject", //$NON-NLS-1$
+ READ_PARAM_TYPES);
+ result.methodReadObjectNoData = findPrivateMethod(cl,
+ "readObjectNoData", EMPTY_CONSTRUCTOR_PARAM_TYPES); //$NON-NLS-1$
if (result.hasMethodWriteObject()) {
flags |= ObjectStreamConstants.SC_WRITE_METHOD;
}
@@ -352,7 +357,7 @@
}
fields = _fields;
}
-
+
/**
* Compute and return the Serial Version UID of the class <code>cl</code>.
* The value is computed based on the class name, superclass chain, field
@@ -695,17 +700,17 @@
}
/**
- * If a Class uses "serialPersistentFields" to define the serialized fields,
+ * If a Class uses "serialPersistentFields" to define the serialized fields,
* this.loadFields cannot get the "unshared" information when deserializing
- * fields using current implementation of ObjectInputStream. This method
+ * fields using current implementation of ObjectInputStream. This method
* provides a way to copy the "unshared" attribute from this.fields.
- *
+ *
*/
private void copyFieldAttributes() {
if ((loadFields == null) || fields == null) {
return;
}
-
+
for (int i = 0; i < loadFields.length; i++) {
ObjectStreamField loadField = loadFields[i];
String name = loadField.getName();
@@ -936,16 +941,16 @@
* a boolean indicating if SUID should be computed or not.
* @return the corresponding descriptor
*/
- private static ObjectStreamClass lookupStreamClass(
- Class<?> cl, boolean computeSUID) {
+ private static ObjectStreamClass lookupStreamClass(Class<?> cl,
+ boolean computeSUID) {
// Synchronized because of the lookup table 'classesAndDescriptors'
- ObjectStreamClass cachedValue;
- synchronized(classesAndDescriptors){
+ ObjectStreamClass cachedValue;
+ synchronized (classesAndDescriptors) {
cachedValue = classesAndDescriptors.get(cl);
if (cachedValue == null) {
- cachedValue = createClassDesc(cl, computeSUID);;
- classesAndDescriptors.put(cl, cachedValue);
+ cachedValue = createClassDesc(cl, computeSUID);
+ classesAndDescriptors.put(cl, cachedValue);
}
}
return cachedValue;
@@ -953,8 +958,8 @@
}
/**
- * Return the java.lang.reflect.Method if class
- * <code>cl</code> implements <code>methodName</code> . Return null otherwise.
+ * Return the java.lang.reflect.Method if class <code>cl</code> implements
+ * <code>methodName</code> . Return null otherwise.
*
* @param cl
* a java.lang.Class which to test
@@ -967,7 +972,7 @@
Method method = null;
while (search != null) {
try {
- method = search.getDeclaredMethod(methodName, (Class[]) null); //$NON-NLS-1$
+ method = search.getDeclaredMethod(methodName, (Class[]) null);
if (search == cl
|| (method.getModifiers() & Modifier.PRIVATE) == 0) {
method.setAccessible(true);
@@ -981,8 +986,8 @@
}
/**
- * Return the java.lang.reflect.Method if class
- * <code>cl</code> implements private <code>methodName</code> . Return null otherwise.
+ * Return the java.lang.reflect.Method if class <code>cl</code> implements
+ * private <code>methodName</code> . Return null otherwise.
*
* @param cl
* a java.lang.Class which to test
@@ -990,10 +995,10 @@
* writeReplace <code>null</code> if the class does not implement
* writeReplace
*/
- static Method findPrivateMethod(Class<?> cl, String methodName, Class[] param) {
+ static Method findPrivateMethod(Class<?> cl, String methodName,
+ Class<?>[] param) {
try {
- Method method = cl
- .getDeclaredMethod(methodName, param); //$NON-NLS-1$
+ Method method = cl.getDeclaredMethod(methodName, param);
if (Modifier.isPrivate(method.getModifiers())
&& method.getReturnType() == VOID_CLASS) {
method.setAccessible(true);
@@ -1005,53 +1010,54 @@
return null;
}
- boolean hasMethodWriteReplace(){
+ boolean hasMethodWriteReplace() {
return (methodWriteReplace != null);
}
- Method getMethodWriteReplace(){
+ Method getMethodWriteReplace() {
return methodWriteReplace;
}
- boolean hasMethodReadResolve(){
+ boolean hasMethodReadResolve() {
return (methodReadResolve != null);
}
- Method getMethodReadResolve(){
+ Method getMethodReadResolve() {
return methodReadResolve;
}
- boolean hasMethodWriteObject(){
+ boolean hasMethodWriteObject() {
return (methodWriteObject != null);
}
- Method getMethodWriteObject(){
+ Method getMethodWriteObject() {
return methodWriteObject;
}
- boolean hasMethodReadObject(){
+ boolean hasMethodReadObject() {
return (methodReadObject != null);
}
- Method getMethodReadObject(){
+ Method getMethodReadObject() {
return methodReadObject;
}
- boolean hasMethodReadObjectNoData(){
+ boolean hasMethodReadObjectNoData() {
return (methodReadObjectNoData != null);
}
- Method getMethodReadObjectNoData(){
+ Method getMethodReadObjectNoData() {
return methodReadObjectNoData;
}
- void initPrivateFields(ObjectStreamClass desc){
+ void initPrivateFields(ObjectStreamClass desc) {
methodWriteReplace = desc.methodWriteReplace;
methodReadResolve = desc.methodReadResolve;
methodWriteObject = desc.methodWriteObject;
methodReadObject = desc.methodReadObject;
methodReadObjectNoData = desc.methodReadObjectNoData;
}
+
/**
* Set the class (java.lang.Class) that the receiver represents
*
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties Wed Oct 31 01:42:07 2007
@@ -21,3 +21,4 @@
luni.04=this Map
luni.05=Attempt to insert {0} element into collection with element type {1}
luni.06=The string argument is null
+luni.07=The stream is corrupted
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/freebsd/OSResourcesMonitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/freebsd/OSResourcesMonitor.c?rev=590591&r1=589774&r2=590591&view=diff
==============================================================================
(empty)
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/linux/OSResourcesMonitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/linux/OSResourcesMonitor.c?rev=590591&r1=589774&r2=590591&view=diff
==============================================================================
(empty)
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile Wed Oct 31 01:42:07 2007
@@ -34,7 +34,7 @@
$(SHAREDSUB)filedesc.o $(SHAREDSUB)timezone.o \
$(SHAREDSUB)OSFileSystem.o OSFileSystemLinux32.o \
OSMemory.o OSMemoryLinux32.o $(SHAREDSUB)OSNetworkSystem.o \
- OSNetworkSystemLinux.o OSResourcesMonitorLinux.o hyenv.o consoleimpl.o
+ OSNetworkSystemLinux.o $(HY_OS)/OSResourcesMonitor.o hyenv.o consoleimpl.o
ifneq ($(HY_ZIP_API),true)
MDLLIBFILES += $(LIBPATH)libhyzip.a $(MDLLIBZLIB)
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSResourcesMonitorWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSResourcesMonitorWin32.c?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSResourcesMonitorWin32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSResourcesMonitorWin32.c Wed Oct 31 01:42:07 2007
@@ -1,46 +1,45 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
/*
* Utilities to monitor system resources.
- */
-
-#include <windows.h>
-#include "OSResourcesMonitor.h"
-
-unsigned long MEMORYFREETHRESHOLD = 32 * 1024 * 1024; //32M
-unsigned int MEMORYLOADTHRESHOLD = 90; //90% load
-
-/*
- * Class: org_apache_harmony_luni_platform_OSResourcesMonitor
- * Method: isSystemPhysicalMemoryLow
- * Signature: ()Z
- */
-JNIEXPORT jboolean JNICALL Java_org_apache_harmony_luni_platform_OSResourcesMonitor_isSystemPhysicalMemoryLow
- (JNIEnv *env, jclass thizClass)
-{
- MEMORYSTATUSEX statex;
- statex.dwLength = sizeof (statex);
-
- if(GlobalMemoryStatusEx(&statex))
- {
- if(statex.dwMemoryLoad >= MEMORYLOADTHRESHOLD || statex.ullAvailPhys <= MEMORYFREETHRESHOLD){
- return TRUE;
- }
- }
- return FALSE;
-}
-
\ No newline at end of file
+ */
+
+#include <windows.h>
+#include "OSResourcesMonitor.h"
+
+unsigned long MEMORYFREETHRESHOLD = 32 * 1024 * 1024; //32M
+unsigned int MEMORYLOADTHRESHOLD = 90; //90% load
+
+/*
+ * Class: org_apache_harmony_luni_platform_OSResourcesMonitor
+ * Method: isSystemPhysicalMemoryLow
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_apache_harmony_luni_platform_OSResourcesMonitor_isSystemPhysicalMemoryLow
+ (JNIEnv *env, jclass thizClass)
+{
+ MEMORYSTATUSEX statex;
+ statex.dwLength = sizeof (statex);
+
+ if(GlobalMemoryStatusEx(&statex))
+ {
+ if(statex.dwMemoryLoad >= MEMORYLOADTHRESHOLD || statex.ullAvailPhys <= MEMORYFREETHRESHOLD){
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSResourcesMonitorWin32.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java Wed Oct 31 01:42:07 2007
@@ -609,8 +609,6 @@
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
- } catch (Exception e) {
- fail("Expected IndexOutOfBoundsException");
}
try {
@@ -618,8 +616,6 @@
fail("Expected NullPointerException");
} catch (NullPointerException e) {
// expected
- } catch (Exception e) {
- fail("Expected NullPointerException");
}
try {
@@ -627,8 +623,6 @@
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
- } catch (Exception e) {
- fail("Expected IndexOutOfBoundsException");
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CompilerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CompilerTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CompilerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CompilerTest.java Wed Oct 31 01:42:07 2007
@@ -25,61 +25,41 @@
* @tests java.lang.Compiler#command(java.lang.Object)
*/
public void test_commandLjava_lang_Object() {
- try {
- assertNull("Incorrect behavior.", Compiler.command(new Object()));
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ assertNull("Incorrect behavior.", Compiler.command(new Object()));
}
/**
* @tests java.lang.Compiler#compileClass(java.lang.Class)
*/
public void test_compileClassLjava_lang_Class() {
- try {
- // Do not test return value, may return true or false depending on
- // if the jit is enabled. Make the call to ensure it doesn't crash.
- Compiler.compileClass(Compiler.class);
- } catch (Exception e) {
- fail("Exception during test.");
- }
+ // Do not test return value, may return true or false depending on
+ // if the jit is enabled. Make the call to ensure it doesn't crash.
+ Compiler.compileClass(Compiler.class);
}
/**
* @tests java.lang.Compiler#compileClasses(java.lang.String)
*/
public void test_compileClassesLjava_lang_String() {
- try {
- // Do not test return value, may return true or false depending on
- // if the jit is enabled. Make the call to ensure it doesn't crash.
+ // Do not test return value, may return true or false depending on
+ // if the jit is enabled. Make the call to ensure it doesn't crash.
Compiler.compileClasses("Compiler");
- } catch (Exception e) {
- fail("Exception during test.");
- }
}
/**
* @tests java.lang.Compiler#disable()
*/
public void test_disable() {
- try {
- Compiler.disable();
- Compiler.compileClass(Compiler.class);
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ Compiler.disable();
+ Compiler.compileClass(Compiler.class);
}
/**
* @tests java.lang.Compiler#enable()
*/
public void test_enable() {
- try {
- Compiler.disable();
- Compiler.enable();
- Compiler.compileClass(Compiler.class);
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ Compiler.disable();
+ Compiler.enable();
+ Compiler.compileClass(Compiler.class);
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/DoubleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/DoubleTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/DoubleTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/DoubleTest.java Wed Oct 31 01:42:07 2007
@@ -1250,9 +1250,7 @@
fail("Expected Double.valueOf(null) to throw NPE.");
} catch (NullPointerException ex) {
// expected
- } catch (Throwable ex) {
- fail("Expected Double.valueOf(null) to throw NPE not " + ex.getClass().getName());
- }
+ }
try {
Double.valueOf("");
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/FloatTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/FloatTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/FloatTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/FloatTest.java Wed Oct 31 01:42:07 2007
@@ -851,8 +851,6 @@
fail("Expected Float.valueOf(null) to throw NPE.");
} catch (NullPointerException ex) {
// expected
- } catch (Exception ex) {
- fail("Expected Float.valueOf(null) to throw NPE not " + ex.getClass().getName());
}
try {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ObjectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ObjectTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ObjectTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ObjectTest.java Wed Oct 31 01:42:07 2007
@@ -52,7 +52,7 @@
/**
* @tests java.lang.Object#getClass()
*/
- public void test_getClass() {
+ public void test_getClass() throws Exception {
// Test for method java.lang.Class java.lang.Object.getClass()
String classNames[] = { "java.lang.Object", "java.lang.Throwable",
"java.lang.StringBuffer" };
@@ -61,17 +61,13 @@
status = 0;
for (int i = 0; i < classNames.length; ++i) {
- try {
- classToTest = Class.forName(classNames[i]);
- instanceToTest = classToTest.newInstance();
- assertTrue("Instance didn't match creator class.",
- instanceToTest.getClass() == classToTest);
- assertTrue("Instance didn't match class with matching name.",
- instanceToTest.getClass() == Class
- .forName(classNames[i]));
- } catch (Exception ex) {
- fail("Unexpected exception : " + ex.getMessage());
- }
+ classToTest = Class.forName(classNames[i]);
+ instanceToTest = classToTest.newInstance();
+ assertTrue("Instance didn't match creator class.",
+ instanceToTest.getClass() == classToTest);
+ assertTrue("Instance didn't match class with matching name.",
+ instanceToTest.getClass() == Class
+ .forName(classNames[i]));
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java Wed Oct 31 01:42:07 2007
@@ -108,7 +108,7 @@
assertTrue("object memory did not grow", secondRead > firstRead);
assertTrue("space was not reclaimed", (r.totalMemory() - r
.freeMemory()) < secondRead);
- } catch (Throwable t) {
+ } catch (OutOfMemoryError oome ) {
System.out.println("Out of memory during freeMemory test");
r.gc();
r.gc();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java Wed Oct 31 01:42:07 2007
@@ -106,11 +106,7 @@
public void test_Constructor$BIILjava_lang_String() throws Exception {
// Test for method java.lang.String(byte [], int, int, java.lang.String)
String s = null;
- try {
- s = new String(new byte[] { 65, 66, 67, 68, 69 }, 0, 5, "8859_1");
- } catch (Exception e) {
- fail("Threw exception : " + e.getMessage());
- }
+ s = new String(new byte[] { 65, 66, 67, 68, 69 }, 0, 5, "8859_1");
assertTrue("Incorrect string returned: " + s, s.equals("ABCDE"));
// Regression for HARMONY-1111
assertNotNull(new String(new byte[] { (byte) 0xC0 }, 0, 1, "UTF-8"));
@@ -119,14 +115,10 @@
/**
* @tests java.lang.String#String(byte[], java.lang.String)
*/
- public void test_Constructor$BLjava_lang_String() {
+ public void test_Constructor$BLjava_lang_String() throws Exception {
// Test for method java.lang.String(byte [], java.lang.String)
String s = null;
- try {
- s = new String(new byte[] { 65, 66, 67, 68, 69 }, "8859_1");
- } catch (Exception e) {
- fail("Threw exception : " + e.getMessage());
- }
+ s = new String(new byte[] { 65, 66, 67, 68, 69 }, "8859_1");
assertTrue("Incorrect string returned: " + s, s.equals("ABCDE"));
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java Wed Oct 31 01:42:07 2007
@@ -39,17 +39,13 @@
UNSAFE_CONSTRUCTOR = uc;
}
- private static String newString(int start, int len, char[] data) {
+ private static String newString(int start, int len, char[] data) throws Exception {
if (UNSAFE_CONSTRUCTOR == null) {
return new String(data, start, len);
}
- try {
- return UNSAFE_CONSTRUCTOR.newInstance(Integer.valueOf(start), Integer.valueOf(len),
+ return UNSAFE_CONSTRUCTOR.newInstance(Integer.valueOf(start), Integer.valueOf(len),
data);
- } catch (Exception e) {
- throw new AssertionError(e);
- }
}
/**
@@ -233,7 +229,7 @@
/**
* @tests java.lang.String#contentEquals(CharSequence)
*/
- public void test_contentEqualsLjava_lang_CharSequence() {
+ public void test_contentEqualsLjava_lang_CharSequence() throws Exception {
String s = "abc";
assertTrue(s.contentEquals((CharSequence) new StringBuffer("abc")));
assertFalse(s.contentEquals((CharSequence) new StringBuffer("def")));
@@ -255,7 +251,7 @@
* @tests java.lang.String#contentEquals(StringBuffer)
*/
@SuppressWarnings("nls")
- public void test_boolean_contentEquals_StringBuffer() {
+ public void test_boolean_contentEquals_StringBuffer() throws Exception {
String s = "abc";
assertTrue(s.contentEquals(new StringBuffer("abc")));
assertFalse(s.contentEquals(new StringBuffer("def")));
@@ -278,7 +274,7 @@
* @tests java.lang.String#contains(CharSequence)
*/
@SuppressWarnings("cast")
- public void test_containsLjava_lang_CharSequence() {
+ public void test_containsLjava_lang_CharSequence() throws Exception {
String s = "abcdefghijklmnopqrstuvwxyz";
assertTrue(s.contains((CharSequence) new StringBuffer("abc")));
assertTrue(s.contains((CharSequence) new StringBuffer("def")));
@@ -299,7 +295,7 @@
/**
* @tests java.lang.String.offsetByCodePoints(int, int)'
*/
- public void test_offsetByCodePointsII() {
+ public void test_offsetByCodePointsII() throws Exception {
int result = new String("a\uD800\uDC00b").offsetByCodePoints(0, 2);
assertEquals(3, result);
@@ -422,7 +418,7 @@
/**
* @tests java.lang.StringBuilder.codePointAt(int)
*/
- public void test_codePointAtI() {
+ public void test_codePointAtI() throws Exception {
String s = "abc";
assertEquals('a', s.codePointAt(0));
assertEquals('b', s.codePointAt(1));
@@ -483,7 +479,7 @@
/**
* @tests java.lang.StringBuilder.codePointBefore(int)
*/
- public void test_codePointBeforeI() {
+ public void test_codePointBeforeI() throws Exception {
String s = "abc";
assertEquals('a', s.codePointBefore(1));
assertEquals('b', s.codePointBefore(2));
@@ -544,7 +540,7 @@
/**
* @tests java.lang.StringBuilder.codePointCount(int, int)
*/
- public void test_codePointCountII() {
+ public void test_codePointCountII() throws Exception {
assertEquals(1, "\uD800\uDC00".codePointCount(0, 2));
assertEquals(1, "\uD800\uDC01".codePointCount(0, 2));
assertEquals(1, "\uD801\uDC01".codePointCount(0, 2));
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/SystemTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/SystemTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/SystemTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/SystemTest.java Wed Oct 31 01:42:07 2007
@@ -101,18 +101,14 @@
*/
public void test_currentTimeMillis() {
// Test for method long java.lang.System.currentTimeMillis()
- try {
- long firstRead = System.currentTimeMillis();
- try {
- Thread.sleep(150);
- } catch (InterruptedException e) {
- }
- long secondRead = System.currentTimeMillis();
- assertTrue("Incorrect times returned: " + firstRead + ", "
- + secondRead, firstRead < secondRead);
- } catch (Exception e) {
- System.out.println("Exception during test: " + e.toString());
- }
+ long firstRead = System.currentTimeMillis();
+ try {
+ Thread.sleep(150);
+ } catch (InterruptedException e) {
+ }
+ long secondRead = System.currentTimeMillis();
+ assertTrue("Incorrect times returned: " + firstRead + ", "
+ + secondRead, firstRead < secondRead);
}
/**
@@ -292,11 +288,7 @@
@SuppressWarnings("deprecation")
public void test_runFinalizersOnExitZ() {
// Can we call the method at least?
- try {
- System.runFinalizersOnExit(false);
- } catch (Throwable t) {
- fail("Failed to set runFinalizersOnExit");
- }
+ System.runFinalizersOnExit(false);
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java Wed Oct 31 01:42:07 2007
@@ -25,11 +25,7 @@
* @tests java.lang.ThreadLocal#ThreadLocal()
*/
public void test_Constructor() {
- try {
- new ThreadLocal<Object>();
- } catch (Exception e) {
- fail("unexpected exception: " + e.toString());
- }
+ new ThreadLocal<Object>();
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java Wed Oct 31 01:42:07 2007
@@ -161,13 +161,9 @@
* @tests java.lang.Thread#Thread(java.lang.Runnable)
*/
public void test_ConstructorLjava_lang_Runnable() {
- // Test for method java.lang.Thread(java.lang.Runnable)
- try {
- ct = new Thread(new SimpleThread(10));
- ct.start();
- } catch (Exception e) {
- fail("Failed to create subthread : " + e.getMessage());
- }
+ // Test for method java.lang.Thread(java.lang.Runnable)
+ ct = new Thread(new SimpleThread(10));
+ ct.start();
}
/**
@@ -305,11 +301,7 @@
* Thread.countStackFrames() is unpredictable, so we just test that it
* doesn't throw an exception.
*/
- try {
- Thread.currentThread().countStackFrames();
- } catch (Throwable t) {
- fail("unexpected throwable: " + t.toString());
- }
+ Thread.currentThread().countStackFrames();
}
/**
@@ -736,28 +728,24 @@
/**
* @tests java.lang.Thread#join(long, int)
*/
- public void test_joinJI() {
+ public void test_joinJI() throws Exception {
// Test for method void java.lang.Thread.join(long, int)
SimpleThread simple;
- try {
- st = new Thread(simple = new SimpleThread(1000), "Squawk1");
- assertTrue("Thread is alive", !st.isAlive());
- synchronized (simple) {
- st.start();
- simple.wait();
- }
-
- long firstRead = System.currentTimeMillis();
- st.join(100, 999999);
- long secondRead = System.currentTimeMillis();
- assertTrue("Did not join by appropriate time: " + secondRead + "-"
- + firstRead + "=" + (secondRead - firstRead), secondRead
- - firstRead <= 300);
- assertTrue("Joined thread is not alive", st.isAlive());
- st.interrupt();
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ st = new Thread(simple = new SimpleThread(1000), "Squawk1");
+ assertTrue("Thread is alive", !st.isAlive());
+ synchronized (simple) {
+ st.start();
+ simple.wait();
+ }
+
+ long firstRead = System.currentTimeMillis();
+ st.join(100, 999999);
+ long secondRead = System.currentTimeMillis();
+ assertTrue("Did not join by appropriate time: " + secondRead + "-"
+ + firstRead + "=" + (secondRead - firstRead), secondRead
+ - firstRead <= 300);
+ assertTrue("Joined thread is not alive", st.isAlive());
+ st.interrupt();
final Object lock = new Object();
final Thread main = Thread.currentThread();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java Wed Oct 31 01:42:07 2007
@@ -29,338 +29,292 @@
/**
* @tests java.net.Inet4Address#isMulticastAddress()
*/
- public void test_isMulticastAddress() {
+ public void test_isMulticastAddress() throws Exception {
// Create 2 IP v4 addresses and call "isMulticastAddress()"
// result should return true if the first 4 bits of the
// address are: 1110, false otherwise
// Make 1 address with 1110, and 1 without
String addrName = "";
- try {
- addrName = "224.0.0.0"; // a multicast addr 1110 = 224-239
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("Multicast address " + addrName + " not detected.", addr
- .isMulticastAddress());
-
- addrName = "239.255.255.255"; // a multicast addr 1110 = 224-239
- addr = InetAddress.getByName(addrName);
- assertTrue("Multicast address " + addrName + " not detected.", addr
- .isMulticastAddress());
-
- addrName = "42.42.42.42"; // a non-multicast address
- addr = InetAddress.getByName(addrName);
- assertTrue("Non multicast address " + addrName
- + " reporting as a multicast address.", !addr
- .isMulticastAddress());
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ addrName = "224.0.0.0"; // a multicast addr 1110 = 224-239
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("Multicast address " + addrName + " not detected.", addr
+ .isMulticastAddress());
+
+ addrName = "239.255.255.255"; // a multicast addr 1110 = 224-239
+ addr = InetAddress.getByName(addrName);
+ assertTrue("Multicast address " + addrName + " not detected.", addr
+ .isMulticastAddress());
+
+ addrName = "42.42.42.42"; // a non-multicast address
+ addr = InetAddress.getByName(addrName);
+ assertTrue("Non multicast address " + addrName
+ + " reporting as a multicast address.", !addr
+ .isMulticastAddress());
}
/**
* @tests java.net.Inet4Address#isAnyLocalAddress()
*/
- public void test_isAnyLocalAddress() {
+ public void test_isAnyLocalAddress() throws Exception {
String addrName = "";
- try {
- addrName = "0.0.0.0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("ANY address " + addrName + " not detected.", addr
- .isAnyLocalAddress());
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ addrName = "0.0.0.0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("ANY address " + addrName + " not detected.", addr
+ .isAnyLocalAddress());
}
/**
* @tests java.net.Inet4Address#isLoopbackAddress()
*/
- public void test_isLoopbackAddress() {
+ public void test_isLoopbackAddress() throws Exception {
// Create some IP V4 addresses and test if they are local...
String addrName = "";
- try {
- addrName = "127.0.0.0"; // a loopback address should be 127.d.d.d
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("Loopback address " + addrName + " not detected.", addr
- .isLoopbackAddress());
-
- addrName = "127.42.42.42"; // a loopback address should be
- // 127.d.d.d
- addr = InetAddress.getByName(addrName);
- assertTrue("Loopback address " + addrName + " not detected.", addr
- .isLoopbackAddress());
-
- addrName = "42.42.42.42"; // a loopback address should be
- // 127.d.d.d
- addr = InetAddress.getByName(addrName);
- assertTrue("Address incorrectly " + addrName
- + " detected as a loopback address.", !addr
- .isLoopbackAddress());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ addrName = "127.0.0.0"; // a loopback address should be 127.d.d.d
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("Loopback address " + addrName + " not detected.", addr
+ .isLoopbackAddress());
+
+ addrName = "127.42.42.42"; // a loopback address should be
+ // 127.d.d.d
+ addr = InetAddress.getByName(addrName);
+ assertTrue("Loopback address " + addrName + " not detected.", addr
+ .isLoopbackAddress());
+
+ addrName = "42.42.42.42"; // a loopback address should be
+ // 127.d.d.d
+ addr = InetAddress.getByName(addrName);
+ assertTrue("Address incorrectly " + addrName
+ + " detected as a loopback address.", !addr
+ .isLoopbackAddress());
}
/**
* @tests java.net.Inet4Address#isLinkLocalAddress()
*/
- public void test_isLinkLocalAddress() {
+ public void test_isLinkLocalAddress() throws Exception {
String addrName = "";
- try {
- // There are no link local addresses for IPv4
- // We'll test one to ensure we get "false"
-
- addrName = "42.42.42.42";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 address " + addrName
- + " incorrectly reporting as a link local address.", !addr
- .isLinkLocalAddress());
- } catch (Exception e) {
- fail("Unknown address : " + e.getMessage());
- }
+ // There are no link local addresses for IPv4
+ // We'll test one to ensure we get "false"
+
+ addrName = "42.42.42.42";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 address " + addrName
+ + " incorrectly reporting as a link local address.", !addr
+ .isLinkLocalAddress());
}
/**
* @tests java.net.Inet4Address#isSiteLocalAddress()
*/
- public void test_isSiteLocalAddress() {
+ public void test_isSiteLocalAddress() throws Exception {
String addrName = "";
- try {
- // There are no site local addresses for IPv4
- // We'll test one to ensure we get "false"
-
- addrName = "42.42.42.42";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 address " + addrName
- + " incorrectly reporting as a site local address.", !addr
- .isSiteLocalAddress());
- } catch (Exception e) {
- fail("Unknown address : " + e.getMessage());
- }
+ // There are no site local addresses for IPv4
+ // We'll test one to ensure we get "false"
+
+ addrName = "42.42.42.42";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 address " + addrName
+ + " incorrectly reporting as a site local address.", !addr
+ .isSiteLocalAddress());
}
/**
* @tests java.net.Inet4Address#isMCGlobal()
*/
- public void test_isMCGlobal() {
+ public void test_isMCGlobal() throws Exception {
// Create an IPv4 mulitcast address. It should return
// false for globabl mutlicast. There are no valid IPv4
// global multicast addresses
String addrName = "";
- try {
- addrName = "224.0.0.0"; // a multicast addr 1110
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 link-local multicast address " + addrName
- + " incorrectly identified as a global multicast address.",
- !addr.isMCGlobal());
-
- addrName = "224.0.0.255"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 link-local multicast address " + addrName
- + " incorrectly identified as a global multicast address.",
- !addr.isMCGlobal());
-
- addrName = "224.0.1.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 global multicast address " + addrName
- + " not identified as a global multicast address.", addr
- .isMCGlobal());
-
- addrName = "238.255.255.255"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 global multicast address " + addrName
- + " not identified as a global multicast address.", addr
- .isMCGlobal());
-
- addrName = "239.0.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 reserved multicast address " + addrName
- + " incorrectly identified as a global multicast address.",
- !addr.isMCGlobal());
-
- addrName = "239.191.255.255"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 reserved multicast address " + addrName
- + " incorrectly identified as a global multicast address.",
- !addr.isMCGlobal());
-
- } catch (Exception e) {
- fail("Unknown address : " + e.getMessage());
- }
+ addrName = "224.0.0.0"; // a multicast addr 1110
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 link-local multicast address " + addrName
+ + " incorrectly identified as a global multicast address.",
+ !addr.isMCGlobal());
+
+ addrName = "224.0.0.255"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 link-local multicast address " + addrName
+ + " incorrectly identified as a global multicast address.",
+ !addr.isMCGlobal());
+
+ addrName = "224.0.1.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 global multicast address " + addrName
+ + " not identified as a global multicast address.", addr
+ .isMCGlobal());
+
+ addrName = "238.255.255.255"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 global multicast address " + addrName
+ + " not identified as a global multicast address.", addr
+ .isMCGlobal());
+
+ addrName = "239.0.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 reserved multicast address " + addrName
+ + " incorrectly identified as a global multicast address.",
+ !addr.isMCGlobal());
+
+ addrName = "239.191.255.255"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 reserved multicast address " + addrName
+ + " incorrectly identified as a global multicast address.",
+ !addr.isMCGlobal());
}
/**
* @tests java.net.Inet4Address#isMCNodeLocal()
*/
- public void test_isMCNodeLocal() {
+ public void test_isMCNodeLocal() throws Exception {
// Create an IPv4 mulitcast address. It should return
// false for node-local mutlicast. There are no valid IPv4
// node-local multicast addresses
String addrName = "";
- try {
- addrName = "224.42.42.42"; // a multicast addr 1110 = 224
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 multicast address "
- + addrName
- + " incorrectly identified as a node-local multicast address.",
- !addr.isMCNodeLocal());
-
- addrName = "239.0.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 reserved multicast address "
- + addrName
- + " incorrectly identified as a node-local multicast address.",
- !addr.isMCNodeLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + e.getMessage());
- }
+ addrName = "224.42.42.42"; // a multicast addr 1110 = 224
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 multicast address "
+ + addrName
+ + " incorrectly identified as a node-local multicast address.",
+ !addr.isMCNodeLocal());
+
+ addrName = "239.0.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 reserved multicast address "
+ + addrName
+ + " incorrectly identified as a node-local multicast address.",
+ !addr.isMCNodeLocal());
}
/**
* @tests java.net.Inet4Address#isMCLinkLocal()
*/
- public void test_isMCLinkLocal() {
+ public void test_isMCLinkLocal() throws Exception {
// Create an IPv4 mulitcast address. It should return
// false for link-local mutlicast. There are no valid IPv4
// link-local multicast addresses
String addrName = "";
- try {
- addrName = "224.0.0.0"; // a multicast addr 1110
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 link-local multicast address " + addrName
- + " not identified as a link-local multicast address.",
- addr.isMCLinkLocal());
-
- addrName = "224.0.0.255"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 link-local multicast address " + addrName
- + " not identified as a link-local multicast address.",
- addr.isMCLinkLocal());
-
- addrName = "224.0.1.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 global multicast address "
- + addrName
- + " incorrectly identified as a link-local multicast address.",
- !addr.isMCLinkLocal());
-
- addrName = "239.0.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 reserved multicast address "
- + addrName
- + " incorrectly identified as a link-local multicast address.",
- !addr.isMCLinkLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ addrName = "224.0.0.0"; // a multicast addr 1110
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 link-local multicast address " + addrName
+ + " not identified as a link-local multicast address.",
+ addr.isMCLinkLocal());
+
+ addrName = "224.0.0.255"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 link-local multicast address " + addrName
+ + " not identified as a link-local multicast address.",
+ addr.isMCLinkLocal());
+
+ addrName = "224.0.1.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 global multicast address "
+ + addrName
+ + " incorrectly identified as a link-local multicast address.",
+ !addr.isMCLinkLocal());
+
+ addrName = "239.0.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 reserved multicast address "
+ + addrName
+ + " incorrectly identified as a link-local multicast address.",
+ !addr.isMCLinkLocal());
}
/**
* @tests java.net.Inet4Address#isMCSiteLocal()
*/
- public void test_isMCSiteLocal() {
+ public void test_isMCSiteLocal() throws Exception {
// Create an IPv4 mulitcast address. It should return
// false for site-local mutlicast. There are no valid IPv4
// site-local multicast addresses
String addrName = "";
- try {
- addrName = "240.0.0.0"; // a multicast addr 1110 = 224
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 multicast address "
- + addrName
- + " incorrectly identified as a site-local multicast address.",
- !addr.isMCSiteLocal());
-
- addrName = "239.0.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 reserved multicast address "
- + addrName
- + " incorrectly identified as a site-local multicast address.",
- !addr.isMCSiteLocal());
-
- addrName = "239.255.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 site-local multicast address " + addrName
- + " not identified as a site-local multicast address.",
- addr.isMCSiteLocal());
-
- addrName = "239.255.255.255"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 site-local multicast address " + addrName
- + " not identified as a site-local multicast address.",
- addr.isMCSiteLocal());
-
- addrName = "239.255.2.2"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 site-local multicast address " + addrName
- + " not identified as a site-local multicast address.",
- addr.isMCSiteLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ addrName = "240.0.0.0"; // a multicast addr 1110 = 224
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 multicast address "
+ + addrName
+ + " incorrectly identified as a site-local multicast address.",
+ !addr.isMCSiteLocal());
+
+ addrName = "239.0.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 reserved multicast address "
+ + addrName
+ + " incorrectly identified as a site-local multicast address.",
+ !addr.isMCSiteLocal());
+
+ addrName = "239.255.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 site-local multicast address " + addrName
+ + " not identified as a site-local multicast address.",
+ addr.isMCSiteLocal());
+
+ addrName = "239.255.255.255"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 site-local multicast address " + addrName
+ + " not identified as a site-local multicast address.",
+ addr.isMCSiteLocal());
+
+ addrName = "239.255.2.2"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 site-local multicast address " + addrName
+ + " not identified as a site-local multicast address.",
+ addr.isMCSiteLocal());
}
/**
* @tests java.net.Inet4Address#isMCOrgLocal()
*/
- public void test_isMCOrgLocal() {
+ public void test_isMCOrgLocal() throws Exception {
// Create an IPv4 mulitcast address. It should return
// false for organization-local mutlicast. There are no valid IPv4
// organization-local multicast addresses
String addrName = "";
- try {
- addrName = "239.191.255.255"; // a multicast addr 1110
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 reserved multicast address "
- + addrName
- + " incorrectly identified as a org-local multicast address.",
- !addr.isMCOrgLocal());
-
- addrName = "239.252.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv4 site-local multicast address "
- + addrName
- + " incorrectly identified as a org-local multicast address.",
- !addr.isMCOrgLocal());
-
- addrName = "239.192.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 org-local multicast address " + addrName
- + " not identified as a org-local multicast address.", addr
- .isMCOrgLocal());
-
- addrName = "239.195.255.255"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 org-local multicast address " + addrName
- + " not identified as a org-local multicast address.", addr
- .isMCOrgLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ addrName = "239.191.255.255"; // a multicast addr 1110
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 reserved multicast address "
+ + addrName
+ + " incorrectly identified as a org-local multicast address.",
+ !addr.isMCOrgLocal());
+
+ addrName = "239.252.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv4 site-local multicast address "
+ + addrName
+ + " incorrectly identified as a org-local multicast address.",
+ !addr.isMCOrgLocal());
+
+ addrName = "239.192.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 org-local multicast address " + addrName
+ + " not identified as a org-local multicast address.", addr
+ .isMCOrgLocal());
+
+ addrName = "239.195.255.255"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 org-local multicast address " + addrName
+ + " not identified as a org-local multicast address.", addr
+ .isMCOrgLocal());
}
// comparator for Inet4Address objects