You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2008/11/27 06:10:42 UTC
svn commit: r721077 [3/12] - in /harmony/enhanced/classlib/branches/java6:
./ depends/files/ depends/jars/ depends/manifests/asm-3.1/
depends/manifests/asm-3.1/META-INF/ depends/manifests/bcel-5.2/ make/
modules/accessibility/ modules/accessibility/src...
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java Wed Nov 26 21:10:32 2008
@@ -431,7 +431,7 @@
* @return <code>true</code> or <code>false</code>
*/
static boolean componentIsOk(String comp) {
- if (comp.indexOf(".") != -1 || comp.length() > //$NON-NLS-1$
+ if (comp.indexOf('.') != -1 || comp.length() >
ProviderConstants.LABEL_MAX_CHARS) {
return false;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java Wed Nov 26 21:10:32 2008
@@ -500,7 +500,9 @@
* "\n", reference.toString());
*/
assertNotNull(reference.toString());
- }
+ assertEquals("Reference Class Name: " + reference.getClassName() + "\n"
+ + addr0.toString() + addr1.toString(), reference.toString());
+ }
public void testToString_AddressNull() {
String className = "java.lang.String";
@@ -510,7 +512,10 @@
* addresses:\n", reference.toString());
*/
assertNotNull(reference.toString());
- }
+ assertEquals(
+ "Reference Class Name: " + reference.getClassName() + "\n",
+ reference.toString());
+ }
public void testClone_Simple() {
String className = "java.lang.String";
Modified: harmony/enhanced/classlib/branches/java6/modules/lang-management/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/lang-management/.classpath?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/lang-management/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/lang-management/.classpath Wed Nov 26 21:10:32 2008
@@ -4,6 +4,6 @@
<classpathentry kind="src" output="bin/test/api" path="src/test/api/java"/>
<classpathentry kind="src" output="bin/test/impl" path="src/test/impl/java"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin/main"/>
</classpath>
Modified: harmony/enhanced/classlib/branches/java6/modules/logging/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/.classpath?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/.classpath Wed Nov 26 21:10:32 2008
@@ -5,6 +5,6 @@
<classpathentry output="bin/test" kind="src" path="src/test/java"/>
<classpathentry output="bin/injected" kind="src" path="src/test/java-internal"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin/main"/>
</classpath>
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/.classpath?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/.classpath Wed Nov 26 21:10:32 2008
@@ -13,6 +13,6 @@
<accessrule kind="accessible" pattern="**/*"/>
</accessrules>
</classpathentry>
- <classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin/main"/>
</classpath>
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF Wed Nov 26 21:10:32 2008
@@ -13,6 +13,7 @@
Eclipse-JREBundle: true
Eclipse-ExtensibleAPI: true
Import-Package: com.ibm.icu.lang,
+ java.awt,
java.lang.annotation,
java.math,
java.nio,
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=721077&r1=721076&r2=721077&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 Nov 26 21:10:32 2008
@@ -270,7 +270,8 @@
char newPath[] = origPath.toCharArray();
for (int i = 0; i < length; i++) {
char pathChar = newPath[i];
- if (pathChar == '\\' || pathChar == '/') {
+ if ((separatorChar == '\\' && pathChar == '\\')
+ || pathChar == '/') {
/* UNC Name requires 2 leading slashes */
if ((foundSlash && i == uncIndex) || !foundSlash) {
newPath[newLength++] = separatorChar;
@@ -736,7 +737,7 @@
* Answers if this File is an absolute pathname. Whether a pathname is
* absolute is platform specific. On UNIX it is if the path starts with the
* character '/', on Windows it is absolute if either it starts with '\',
- * '/', '\\' (to represent a file server), or a letter followed by a colon.
+ * '/', '\\' (to represent a file server), or a letter followed by ':\'.
*
* @return <code>true</code> if this File is absolute, <code>false</code>
* otherwise.
@@ -1292,18 +1293,23 @@
* @throws IOException
* If an error occurs when writing the file
*/
+ @SuppressWarnings("nls")
public static File createTempFile(String prefix, String suffix,
File directory) throws IOException {
// Force a prefix null check first
if (prefix.length() < 3) {
- throw new IllegalArgumentException(Msg.getString("K006b")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Msg.getString("K006b"));
+ }
+ String newSuffix = suffix == null ? ".tmp" : suffix;
+ File tmpDirFile;
+ if (directory == null) {
+ String tmpDir = AccessController.doPrivileged(
+ new PriviAction<String>("java.io.tmpdir", "."));
+ tmpDirFile = new File(tmpDir);
+ } else {
+ tmpDirFile = directory;
}
- String newSuffix = suffix == null ? ".tmp" : suffix; //$NON-NLS-1$
- String tmpDir = "."; //$NON-NLS-1$
- tmpDir = AccessController.doPrivileged(new PriviAction<String>(
- "java.io.tmpdir", ".")); //$NON-NLS-1$//$NON-NLS-2$
- File result, tmpDirFile = directory == null ? new File(tmpDir)
- : directory;
+ File result;
do {
result = genTempFile(prefix, newSuffix, tmpDirFile);
} while (!result.createNewFile());
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=721077&r1=721076&r2=721077&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 Nov 26 21:10:32 2008
@@ -495,13 +495,13 @@
}
/**
- * Return the next <code>int</code> handle to be used to indicate cyclic
+ * Return the next <code>Integer</code> handle to be used to indicate cyclic
* references being loaded from the stream.
*
* @return the next handle to represent the next cyclic reference
*/
- private int nextHandle() {
- return this.currentHandle++;
+ private Integer nextHandle() {
+ return Integer.valueOf(this.currentHandle++);
}
/**
@@ -1121,7 +1121,7 @@
byte srcByte = input.readByte();
if (fieldID != ObjectStreamField.FIELD_IS_ABSENT) {
accessor.setByte(obj, fieldID, srcByte);
- };
+ }
break;
case 'C':
char srcChar = input.readChar();
@@ -1457,7 +1457,6 @@
*
* @deprecated Use BufferedReader
*/
- @SuppressWarnings("deprecation")
@Deprecated
public String readLine() throws IOException {
return primitiveTypes.readLine();
@@ -1626,7 +1625,7 @@
ObjectStreamClass classDesc;
primitiveData = input;
Integer oldHandle = descriptorHandle;
- descriptorHandle = Integer.valueOf(nextHandle());
+ descriptorHandle = nextHandle();
classDesc = readClassDescriptor();
registerObjectRead(classDesc, descriptorHandle, false);
descriptorHandle = oldHandle;
@@ -1660,7 +1659,7 @@
ClassNotFoundException, IOException {
// read classdesc for Enum first
ObjectStreamClass classDesc = readEnumDesc();
- int newHandle = nextHandle();
+ Integer newHandle = nextHandle();
// read name after class desc
String name;
byte tc = nextTC();
@@ -2523,7 +2522,7 @@
}
private static String getBaseName(String fullName) {
- int k = fullName.lastIndexOf("."); //$NON-NLS-1$
+ int k = fullName.lastIndexOf('.');
if (k == -1 || k == (fullName.length() - 1)) {
return fullName;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java Wed Nov 26 21:10:32 2008
@@ -428,13 +428,13 @@
/**
- * Return the next <code>int</code> handle to be used to indicate cyclic
+ * Return the next <code>Integer</code> handle to be used to indicate cyclic
* references being saved to the stream.
*
- * @return int, the next handle to represent the next cyclic reference
+ * @return the next handle to represent the next cyclic reference
*/
- private int nextHandle() {
- return this.currentHandle++;
+ private Integer nextHandle() {
+ return Integer.valueOf(this.currentHandle++);
}
/**
@@ -473,8 +473,8 @@
*
* @see #nextHandle
*/
- private int registerObjectWritten(Object obj) {
- int handle = nextHandle();
+ private Integer registerObjectWritten(Object obj) {
+ Integer handle = nextHandle();
objectsWritten.put(obj, handle);
return handle;
}
@@ -1168,7 +1168,7 @@
output.writeByte(TC_ARRAY);
writeClassDesc(arrayClDesc, false);
- int handle = nextHandle();
+ Integer handle = nextHandle();
if (!unshared) {
objectsWritten.put(array, handle);
@@ -1279,7 +1279,7 @@
writeClassDesc(clDesc, unshared);
}
- int handle = nextHandle();
+ Integer handle = nextHandle();
if (!unshared) {
objectsWritten.put(object, handle);
@@ -1415,7 +1415,7 @@
if (unshared) {
previousHandle = objectsWritten.get(object);
}
- int handle = nextHandle();
+ Integer handle = nextHandle();
objectsWritten.put(object, handle);
// This is how we know what to do in defaultWriteObject. And it is also
@@ -1487,7 +1487,7 @@
}
output.writeUTFBytes(object, count);
- int handle = nextHandle();
+ Integer handle = nextHandle();
if (!unshared) {
objectsWritten.put(object, handle);
@@ -1791,7 +1791,7 @@
if (unshared) {
previousHandle = objectsWritten.get(object);
}
- int handle = nextHandle();
+ Integer handle = nextHandle();
objectsWritten.put(object, handle);
ObjectStreamField[] fields = classDesc.getSuperclass().fields();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java Wed Nov 26 21:10:32 2008
@@ -457,15 +457,72 @@
return;
}
if (!shared) {
- for (int i = 0, end = count, mid = count / 2; i < mid; i++) {
- char temp = value[--end];
- value[end] = value[i];
- value[i] = temp;
+ int end = count - 1;
+ char frontHigh = value[0];
+ char endLow = value[end];
+ boolean allowFrontSur = true, allowEndSur = true;
+ for (int i = 0, mid = count / 2; i < mid; i++, --end) {
+ char frontLow = value[i + 1];
+ char endHigh = value[end - 1];
+ boolean surAtFront = allowFrontSur && frontLow >= 0xdc00
+ && frontLow <= 0xdfff && frontHigh >= 0xd800
+ && frontHigh <= 0xdbff;
+ if (surAtFront && (count < 3)) {
+ return;
+ }
+ boolean surAtEnd = allowEndSur && endHigh >= 0xd800
+ && endHigh <= 0xdbff && endLow >= 0xdc00
+ && endLow <= 0xdfff;
+ allowFrontSur = allowEndSur = true;
+ if (surAtFront == surAtEnd) {
+ if (surAtFront) {
+ // both surrogates
+ value[end] = frontLow;
+ value[end - 1] = frontHigh;
+ value[i] = endHigh;
+ value[i + 1] = endLow;
+ frontHigh = value[i + 2];
+ endLow = value[end - 2];
+ i++;
+ end--;
+ } else {
+ // neither surrogates
+ value[end] = frontHigh;
+ value[i] = endLow;
+ frontHigh = frontLow;
+ endLow = endHigh;
+ }
+ } else {
+ if (surAtFront) {
+ // surrogate only at the front
+ value[end] = frontLow;
+ value[i] = endLow;
+ endLow = endHigh;
+ allowFrontSur = false;
+ } else {
+ // surrogate only at the end
+ value[end] = frontHigh;
+ value[i] = endHigh;
+ frontHigh = frontLow;
+ allowEndSur = false;
+ }
+ }
+ }
+ if ((count & 1) == 1 && (!allowFrontSur || !allowEndSur)) {
+ value[end] = allowFrontSur ? endLow : frontHigh;
}
} else {
char[] newData = new char[value.length];
for (int i = 0, end = count; i < count; i++) {
- newData[--end] = value[i];
+ char high = value[i];
+ if ((i + 1) < count && high >= 0xd800 && high <= 0xdbff) {
+ char low = value[i + 1];
+ if (low >= 0xdc00 && low <= 0xdfff) {
+ newData[--end] = low;
+ i++;
+ }
+ }
+ newData[--end] = high;
}
value = newData;
shared = false;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Proxy.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Proxy.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Proxy.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Proxy.java Wed Nov 26 21:10:32 2008
@@ -146,7 +146,7 @@
WeakReference<Class<?>> ref = interfaceCache.get(interfaceKey);
if (ref == null) {
String nextClassName = "$Proxy" + NextClassNameIndex++; //$NON-NLS-1$
- if (commonPackageName != null) {
+ if (commonPackageName != null && commonPackageName.length() > 0) {
nextClassName = commonPackageName + "." + nextClassName; //$NON-NLS-1$
}
byte[] classFileBytes = ProxyClassFile.generateBytes(
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java Wed Nov 26 21:10:32 2008
@@ -56,12 +56,11 @@
* the initial capacity of this ArrayList
*/
public ArrayList(int capacity) {
- firstIndex = lastIndex = 0;
- try {
- array = newElementArray(capacity);
- } catch (NegativeArraySizeException e) {
+ if (capacity < 0) {
throw new IllegalArgumentException();
}
+ firstIndex = lastIndex = 0;
+ array = newElementArray(capacity);
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/InputMismatchException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/InputMismatchException.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/InputMismatchException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/InputMismatchException.java Wed Nov 26 21:10:32 2008
@@ -26,7 +26,7 @@
public class InputMismatchException extends NoSuchElementException implements
Serializable {
- static final long serialVersionUID = 8811230760997066428L;
+ private static final long serialVersionUID = 8811230760997066428L;
/**
* Constructs a InputMismatchException with no error message
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/PriorityQueue.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/PriorityQueue.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/PriorityQueue.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/PriorityQueue.java Wed Nov 26 21:10:32 2008
@@ -92,7 +92,7 @@
* queue to be constructed.
* @throws ClassCastException if any of the elements in the collection is
* not comparable.
- * @throws NullPointerExcepiton if any of the elements in the collection is
+ * @throws NullPointerException if any of the elements in the collection is
* null.
*/
public PriorityQueue(Collection<? extends E> c) {
@@ -170,7 +170,7 @@
* @throws ClassCastException if the element cannot be compared with the
* elements in the priority queue using the ordering of the priority
* queue.
- * @throws NullPointerExcepiton if the element is null.
+ * @throws NullPointerException if the element is null.
*/
public boolean offer(E o) {
if (null == o) {
@@ -248,7 +248,7 @@
* @throws ClassCastException if the element cannot be compared with the
* elements in the priority queue using the ordering of the priority
* queue.
- * @throws NullPointerExcepiton if the element is null.
+ * @throws NullPointerException if the element is null.
*/
@Override
public boolean add(E o) {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java Wed Nov 26 21:10:32 2008
@@ -29,15 +29,15 @@
* excessive amount of time to run it may impact the time at which subsequent
* tasks may run.
* <p>
- *
+ *
* The Timer task does not offer any guarantees about the real-time nature of
* scheduling tasks as it's underlying implementation relies on the
* <code>Object.wait(long)</code> method.
* <p>
- *
+ *
* Multiple threads can share a single Timer without the need for their own
* synchronization.
- *
+ *
* @see TimerTask
* @see java.lang.Object#wait(long)
*/
@@ -67,7 +67,7 @@
TimerTask[] appendedTimers = new TimerTask[size * 2];
System.arraycopy(timers, 0, appendedTimers, 0, size);
timers = appendedTimers;
- }
+ }
timers[size++] = task;
upHeap();
}
@@ -109,8 +109,9 @@
}
// compare selected child with parent
- if (timers[current].when < timers[child].when)
+ if (timers[current].when < timers[child].when) {
break;
+ }
// swap the two
TimerTask tmp = timers[current];
@@ -142,10 +143,10 @@
}
}
}
-
+
private int getTask(TimerTask task) {
for (int i = 0; i < timers.length; i++) {
- if (timers[i] == task){
+ if (timers[i] == task) {
return i;
}
}
@@ -154,7 +155,6 @@
}
-
/**
* True if the method cancel() of the Timer was called or the !!!stop()
* method was invoked
@@ -174,7 +174,7 @@
/**
* Starts a new timer.
- *
+ *
* @param isDaemon
*/
TimerImpl(boolean isDaemon) {
@@ -242,7 +242,7 @@
synchronized (task.lock) {
int pos = 0;
- if(tasks.minimum().when != task.when){
+ if (tasks.minimum().when != task.when) {
pos = tasks.getTask(task);
}
if (task.cancelled) {
@@ -329,7 +329,7 @@
/**
* Creates a new Timer which may be specified to be run as a Daemon Thread.
- *
+ *
* @param isDaemon
* true if Timers thread should be a daemon thread.
*/
@@ -344,10 +344,31 @@
impl = new TimerImpl(false);
}
+ /**
+ * Create a new timer with the given name and daemon status.
+ *
+ * The name is given the timer's background thread and if the flag is true
+ * the thread is run as a daemon.
+ *
+ * @param name
+ * a name to associate with the timer thread.
+ * @param isDaemon
+ * true if the timer thread should be a daemon, or false if it is
+ * a regular thread that prevents the application terminating.
+ */
public Timer(String name, boolean isDaemon) {
impl = new TimerImpl(name, isDaemon);
}
+ /**
+ * Create a new timer whose thread has the given name.
+ *
+ * The name is given the timer's background thread, that is not run as a
+ * daemon.
+ *
+ * @param name
+ * a name to associate with the timer thread.
+ */
public Timer(String name) {
impl = new TimerImpl(name, false);
}
@@ -361,6 +382,16 @@
impl.cancel();
}
+ /**
+ * Purging the timer eagerly removes cancelled tasks.
+ *
+ * When a large number of tasks have been cancelled it may be helpful to
+ * explicitly purge them from the timer rather than let them be removed
+ * during normal expiry processing. This is a housekeeping task that does
+ * not affect the timer's schedule tasks.
+ *
+ * @return the number of tasks that were purged.
+ */
public int purge() {
synchronized (impl) {
return impl.purge();
@@ -370,12 +401,12 @@
/**
* Schedule a task for single execution. If when is less than the current
* time, it will be scheduled to executed as soon as possible.
- *
+ *
* @param task
* The task to schedule
* @param when
* Time of execution
- *
+ *
* @exception IllegalArgumentException
* if when.getTime() < 0
* @exception IllegalStateException
@@ -392,12 +423,12 @@
/**
* Schedule a task for single execution after a specific delay.
- *
+ *
* @param task
* The task to schedule
* @param delay
* Amount of time before execution
- *
+ *
* @exception IllegalArgumentException
* if delay < 0
* @exception IllegalStateException
@@ -413,14 +444,14 @@
/**
* Schedule a task for repeated fix-delay execution after a specific delay.
- *
+ *
* @param task
* The task to schedule
* @param delay
* Amount of time before first execution
* @param period
* Amount of time between subsequent executions
- *
+ *
* @exception IllegalArgumentException
* if delay < 0 or period < 0
* @exception IllegalStateException
@@ -437,14 +468,14 @@
/**
* Schedule a task for repeated fix-delay execution after a specific time
* has been reached.
- *
+ *
* @param task
* The task to schedule
* @param when
* Time of first execution
* @param period
* Amount of time between subsequent executions
- *
+ *
* @exception IllegalArgumentException
* if when.getTime() < 0 or period < 0
* @exception IllegalStateException
@@ -464,14 +495,14 @@
* has been happened. The difference of fixed-rate is that it may bunch up
* subsequent task runs to try to get the task repeating at it's desired
* time.
- *
+ *
* @param task
* The task to schedule
* @param delay
* Amount of time before first execution
* @param period
* Amount of time between subsequent executions
- *
+ *
* @exception IllegalArgumentException
* if delay < 0 or period < 0
* @exception IllegalStateException
@@ -490,14 +521,14 @@
* has been reached. The difference of fixed-rate is that it may bunch up
* subsequent task runs to try to get the task repeating at it's desired
* time.
- *
+ *
* @param task
* The task to schedule
* @param when
* Time of first execution
* @param period
* Amount of time between subsequent executions
- *
+ *
* @exception IllegalArgumentException
* if when.getTime() < 0 or period < 0
* @exception IllegalStateException
@@ -512,13 +543,8 @@
scheduleImpl(task, delay < 0 ? 0 : delay, period, true);
}
- /**
+ /*
* Schedule a task.
- *
- * @param task
- * @param delay
- * @param period
- * @param fixed
*/
private void scheduleImpl(TimerTask task, long delay, long period,
boolean fixed) {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java Wed Nov 26 21:10:32 2008
@@ -88,12 +88,11 @@
* the amount to increase the capacity when this Vector is full
*/
public Vector(int capacity, int capacityIncrement) {
- elementCount = 0;
- try {
- elementData = newElementArray(capacity);
- } catch (NegativeArraySizeException e) {
+ if (capacity < 0) {
throw new IllegalArgumentException();
}
+ elementData = newElementArray(capacity);
+ elementCount = 0;
this.capacityIncrement = capacityIncrement;
}
@@ -760,7 +759,9 @@
* @see #size
*/
public synchronized void removeAllElements() {
- Arrays.fill(elementData, 0, elementCount, null);
+ for (int i = 0; i < elementCount; i++) {
+ elementData[i] = null;
+ }
modCount++;
elementCount = 0;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java Wed Nov 26 21:10:32 2008
@@ -73,7 +73,7 @@
final SystemProcess p = new SystemProcess();
- p.lock = new Lock();
+ p.lock = new Object();
Runnable waitingThread = new Runnable() {
public void run() {
@@ -104,9 +104,7 @@
synchronized (p.lock) {
p.closeImpl();
p.handle = -1;
- }
- p.exitCodeAvailable = true;
- synchronized (p.lock) {
+ p.exitCodeAvailable = true;
try {
p.in.close();
} catch (IOException e) {
@@ -119,25 +117,29 @@
wait.setDaemon(true);
wait.start();
- try {
- synchronized (p.lock) {
- while (!p.waiterStarted) {
+ synchronized (p.lock) {
+ boolean interrupted = false;
+ while (!p.waiterStarted) {
+ try {
p.lock.wait();
+ } catch (InterruptedException e) {
+ interrupted = true;
}
- if (p.exception != null) {
- /* Re-throw exception that originated in the helper thread */
- p.exception.fillInStackTrace();
- if (p.exception instanceof IOException) {
- throw (IOException) p.exception;
- } else if (p.exception instanceof Error) {
- throw (Error) p.exception;
- } else {
- throw (RuntimeException) p.exception;
- }
+ }
+ if (interrupted) {
+ Thread.currentThread().interrupt();
+ }
+ if (p.exception != null) {
+ /* Re-throw exception that originated in the helper thread */
+ p.exception.fillInStackTrace();
+ if (p.exception instanceof IOException) {
+ throw (IOException) p.exception;
+ } else if (p.exception instanceof Error) {
+ throw (Error) p.exception;
+ } else {
+ throw (RuntimeException) p.exception;
}
}
- } catch (InterruptedException e) {
- throw new InternalError();
}
return p;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/DeleteOnExit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/DeleteOnExit.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/DeleteOnExit.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/DeleteOnExit.java Wed Nov 26 21:10:32 2008
@@ -35,15 +35,9 @@
}
public static void deleteOnExit() {
- java.util.Collections.sort(deleteList,
- new java.util.Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.length() - s1.length();
- }
- });
- for (int i = 0; i < deleteList.size(); i++) {
- String name = deleteList.elementAt(i);
- new File(name).delete();
- }
+ for (int i = deleteList.size() - 1; i >= 0; i--) {
+ String name = deleteList.elementAt(i);
+ new File(name).delete();
+ }
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c Wed Nov 26 21:10:32 2008
@@ -519,7 +519,7 @@
/* If there is already a classpath argument, we add our tools to it */
for (i = 1; i < argc; i++) {
if ((0 == strncmp (argv[i], "-J-cp", 5)) ||
- (0 == strncmp (argv[i], "-J-classpath", 11))) {
+ (0 == strncmp (argv[i], "-J-classpath", 12))) {
classpath = argv[++i];
if (NULL == classpath) {
return 1;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c Wed Nov 26 21:10:32 2008
@@ -30,7 +30,10 @@
I_32 result;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -45,7 +48,10 @@
I_32 result;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -64,7 +70,7 @@
PORT_ACCESS_FROM_ENV (env);
jsize length = (*env)->GetArrayLength (env, path);
- char pathCopy[HyMaxPath];
+ char pathCopy[HyMaxPath+1]; // allow room to add trailing /
char filename[HyMaxPath];
I_32 result = 0, index;
I_32 numEntries = 0;
@@ -75,7 +81,10 @@
dirList = NULL;
currentEntry = NULL;
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length >= HyMaxPath) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
if (length >= 1 && pathCopy[length - 1] != '\\'
&& pathCopy[length - 1] != '/')
@@ -154,7 +163,10 @@
I_32 result;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -169,7 +181,10 @@
I_32 result;
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -232,7 +247,10 @@
I_32 result;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -248,7 +266,10 @@
I_64 result;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -264,7 +285,10 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -313,7 +337,10 @@
I_32 result;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -330,11 +357,17 @@
jsize length;
char pathExistCopy[HyMaxPath], pathNewCopy[HyMaxPath];
length = (*env)->GetArrayLength (env, pathExist);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "old path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, pathExist, 0, length, (jbyte *)pathExistCopy));
pathExistCopy[length] = '\0';
length = (*env)->GetArrayLength (env, pathNew);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "new path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, pathNew, 0, length, (jbyte *)pathNewCopy));
pathNewCopy[length] = '\0';
ioh_convertToPlatform (pathExistCopy);
@@ -353,7 +386,10 @@
jsize answerlen;
char pathCopy[HyMaxPath];
U_32 length = (U_32) (*env)->GetArrayLength (env, path);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
(*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy);
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -374,7 +410,10 @@
IDATA portFD;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -442,7 +481,10 @@
I_32 result;
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -457,7 +499,10 @@
I_32 result;
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -473,7 +518,10 @@
{
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -535,7 +583,10 @@
I_32 result;
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -550,7 +601,10 @@
I_32 result;
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
@@ -565,7 +619,10 @@
jsize answerlen;
char pathCopy[HyMaxPath];
U_32 length = (U_32) (*env)->GetArrayLength (env, path);
- length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ if (length > HyMaxPath-1) {
+ throwJavaIoIOException(env, "path exceeds maximum supported length");
+ return 0;
+ }
(*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy);
pathCopy[length] = '\0';
ioh_convertToPlatform (pathCopy);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c Wed Nov 26 21:10:32 2008
@@ -41,7 +41,6 @@
PORT_ACCESS_FROM_ENV (env);
hytimeval_struct timeP;
I_32 result = 0;
- I_32 size = 0;
jobject gotFD;
hyfdset_t fdset_read,fdset_write;
hysocket_t hysocketP;
@@ -63,18 +62,14 @@
if (!hysock_socketIsValid (hysocketP)){
continue;
- }
+ }
if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK)
{
FD_SET (hysocketP->ipv4, &fdset_read->handle);
- if (0 > (size - hysocketP->ipv4))
- size = hysocketP->ipv4;
}
if (hysocketP->flags & SOCKET_IPV6_OPEN_MASK)
{
FD_SET (hysocketP->ipv6, &fdset_read->handle);
- if (0 > (size - hysocketP->ipv6))
- size = hysocketP->ipv6;
}
}
for (val = 0; val<countWriteC; val++){
@@ -88,34 +83,21 @@
if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK)
{
FD_SET (hysocketP->ipv4, &fdset_write->handle);
- if (0 > (size - hysocketP->ipv4))
- size = hysocketP->ipv4;
}
if (hysocketP->flags & SOCKET_IPV6_OPEN_MASK)
{
FD_SET (hysocketP->ipv6, &fdset_write->handle);
- if (0 > (size - hysocketP->ipv6))
- size = hysocketP->ipv6;
}
}
- /* the size is the max_fd + 1 */
- size =size + 1;
- if (0 > size)
- {
- result = HYPORT_ERROR_SOCKET_FDSET_SIZEBAD;
- }
- else
- {
- /* only set when timeout >= 0 (non-block)*/
- if (0 <= timeout){
- hysock_timeval_init ( time_sec, time_msec, &timeP);
- result = hysock_select (size, fdset_read, fdset_write, NULL,&timeP);
- }
- else{
- result = hysock_select (size, fdset_read, fdset_write, NULL,NULL);
- }
- }
+ /* only set when timeout >= 0 (non-block)*/
+ if (0 <= timeout){
+ hysock_timeval_init ( time_sec, time_msec, &timeP);
+ result = hysock_select (0, fdset_read, fdset_write, NULL, &timeP);
+ }
+ else{
+ result = hysock_select (0, fdset_read, fdset_write, NULL,NULL);
+ }
if (0 < result){
/*output the reslut to a int array*/
@@ -183,7 +165,7 @@
hytimeval_struct timeP;
hyfdset_t fdset_read;
I_32 result = 0;
- I_32 size = 0;
+
if (0 <= uSecTime)
hysock_timeval_init (0, uSecTime, &timeP);
@@ -192,17 +174,15 @@
if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK)
{
FD_SET (hysocketP->ipv4, &fdset_read->handle);
- size =hysocketP->ipv4 + 1;
}
if (hysocketP->flags & SOCKET_IPV6_OPEN_MASK)
{
FD_SET (hysocketP->ipv6, &fdset_read->handle);
- size =hysocketP->ipv6 + 1;
}
if (0 <= uSecTime)
- result = hysock_select (size, fdset_read, NULL, NULL,&timeP);
+ result = hysock_select (0, fdset_read, NULL, NULL,&timeP);
else
- result = hysock_select (size, fdset_read, NULL, NULL,NULL);
+ result = hysock_select (0, fdset_read, NULL, NULL,NULL);
hymem_free_memory(fdset_read);
return result;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/vmls/shared/vmls.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/vmls/shared/vmls.c?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/vmls/shared/vmls.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/vmls/shared/vmls.c Wed Nov 26 21:10:32 2008
@@ -250,6 +250,7 @@
cursor->vmLocalStorage[((UDATA) *pKey) - 1] = value;
return value;
}
+ cursor = cursor->linkNext;
}
return value;
@@ -300,10 +301,10 @@
/* Allocate a new container */
container = hymem_allocate_memory(sizeof(VMLSContainer));
- if (container) {
- memset(container,0,sizeof(VMLSContainer));
- container->javaVM = vm;
- }
+ if (!container) return;
+
+ memset(container,0,sizeof(VMLSContainer));
+ container->javaVM = vm;
/* Insert it into the list */
container->linkNext = vmls->containerHead;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java Wed Nov 26 21:10:32 2008
@@ -194,11 +194,27 @@
char[] ca = new char[2];
BufferedReader toRet = new BufferedReader(new InputStreamReader(
new ByteArrayInputStream(new byte[0])));
+
+ /* Null buffer should throw NPE even when len == 0 */
+ try {
+ toRet.read(null, 1, 0);
+ fail("null buffer reading zero bytes should throw NPE");
+ } catch (NullPointerException e) {
+ //expected
+ }
+
try {
toRet.close();
} catch (IOException e) {
fail("unexpected 1: " + e);
}
+
+ try {
+ toRet.read(null, 1, 0);
+ fail("null buffer reading zero bytes on closed stream should throw IOException");
+ } catch (IOException e) {
+ //expected
+ }
/* Closed reader should throw IOException reading zero bytes */
try {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java Wed Nov 26 21:10:32 2008
@@ -37,6 +37,8 @@
FilePermission readInFile = new FilePermission("aFile.file", "read");
+ FilePermission readInSubdir = new FilePermission("-", "read");
+
/**
* @tests java.io.FilePermission#FilePermission(java.lang.String,
* java.lang.String)
@@ -90,64 +92,73 @@
*/
public void test_equalsLjava_lang_Object() {
assertTrue(
- "returned false when two instance of FilePermission is equal",
+ "Should not returned false when two instance of FilePermission is equal",
readAllFiles.equals(alsoReadAllFiles));
- assertTrue(
- "returned true when two instance of FilePermission is not equal",
- !(readInCurrent.equals(readInFile)));
+ assertFalse(
+ "Should not returned true when two instance of FilePermission is not equal",
+ readInCurrent.equals(readInFile));
}
/**
* @tests java.io.FilePermission#implies(java.security.Permission)
*/
public void test_impliesLjava_security_Permission() {
- assertTrue("Returned true for non-subset of actions", !readAllFiles
+ assertFalse("Should not return true for non-subset of actions", readAllFiles
.implies(allInCurrent));
- assertTrue("Returned true for non-subset of files", !allInCurrent
+ assertFalse("Should not return true for non-subset of files", allInCurrent
.implies(readAllFiles));
- assertTrue("Returned false for subset of actions", allInCurrent
+ assertTrue("Should not return false for subset of actions", allInCurrent
.implies(readInCurrent));
- assertTrue("Returned false for subset of files", readAllFiles
+ assertTrue("Should not return false for subset of files", readAllFiles
.implies(readInCurrent));
- assertTrue("Returned false for subset of files and actions",
+ assertTrue("Should not return false for subset of files and actions",
allInCurrent.implies(readInFile));
- assertTrue("Returned false for equal FilePermissions", readAllFiles
+ assertTrue("Should not return false for equal FilePermissions", readAllFiles
.implies(alsoReadAllFiles));
+ assertTrue("Should not return false for subdir self", readInSubdir.implies(readInSubdir));
+ assertTrue("Should not return false for current self", readInCurrent.implies(readInCurrent));
+ assertTrue("Should not return false for subdir", readInSubdir.implies(readInCurrent));
+
+ FilePermission fp13 = new FilePermission(File.separator, "read");
+ FilePermission fp14 = new FilePermission(File.separator + "*", "read");
+ assertFalse("/ should not imply /*", fp13.implies(fp14));
+ fp14 = new FilePermission(File.separator + "-", "read");
+ assertFalse("/ should not imply /-", fp13.implies(fp14));
FilePermission fp3 = new FilePermission("/bob/*".replace('/',
File.separatorChar), "read,write");
FilePermission fp4 = new FilePermission("/bob/".replace('/',
File.separatorChar), "write");
- assertTrue("returned true for same dir using * and not *", !fp3
+ assertFalse("Should not return true for same dir using * and not *", fp3
.implies(fp4));
FilePermission fp5 = new FilePermission("/bob/file".replace('/',
File.separatorChar), "write");
- assertTrue("returned false for same dir using * and file", fp3
+ assertTrue("Should not return false for same dir using * and file", fp3
.implies(fp5));
FilePermission fp6 = new FilePermission("/bob/".replace('/',
File.separatorChar), "read,write");
FilePermission fp7 = new FilePermission("/bob/*".replace('/',
File.separatorChar), "write");
- assertTrue("returned false for same dir using not * and *", !fp6
+ assertFalse("Should not return true for same dir using not * and *", fp6
.implies(fp7));
- assertTrue("returned false for same subdir", fp6.implies(fp4));
+ assertTrue("Should not return false for same subdir", fp6.implies(fp4));
FilePermission fp8 = new FilePermission("/".replace('/',
File.separatorChar), "read,write");
FilePermission fp9 = new FilePermission("/".replace('/',
File.separatorChar), "write");
- assertTrue("returned false for same dir", fp8.implies(fp9));
+ assertTrue("Should not return false for same dir", fp8.implies(fp9));
FilePermission fp10 = new FilePermission("/".replace('/',
File.separatorChar), "read,write");
FilePermission fp11 = new FilePermission("/".replace('/',
File.separatorChar), "write");
- assertTrue("returned false for same dir", fp10.implies(fp11));
+ assertTrue("Should not return false for same dir", fp10.implies(fp11));
FilePermission fp12 = new FilePermission("/*".replace('/',
File.separatorChar), "read,write");
- assertTrue("returned false for same dir using * and dir", !fp12
+ assertFalse("Should not return true for same dir using * and dir", fp12
.implies(fp10));
// Regression for HARMONY-47
@@ -178,11 +189,11 @@
for (int i = 0; i < perm.length; i++) {
collect.add(perm[i]);
}
- assertTrue("returned false for subset of files", collect
+ assertTrue("Should not return false for subset of files", collect
.implies(new FilePermission("*", "write")));
- assertTrue("returned false for subset of name and action", collect
+ assertTrue("Should not return false for subset of name and action", collect
.implies(new FilePermission(s + "tmp", "read")));
- assertTrue("returned true for non subset of file and action", collect
+ assertTrue("Should not return false for non subset of file and action", collect
.implies(readInFile));
FilePermission fp1 = new FilePermission("/tmp/-".replace('/',
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java Wed Nov 26 21:10:32 2008
@@ -122,8 +122,13 @@
File file = new File(root, "/dir/file");
assertEquals("Assert 1: wrong path result ", path.getPath(), file
.getPath());
- assertTrue("Assert 1.1: path not absolute ", new File("\\\\\\a\b")
- .isAbsolute());
+ if (File.separatorChar == '\\') {
+ assertTrue("Assert 1.1: path not absolute ", new File("\\\\\\a\b")
+ .isAbsolute());
+ } else {
+ assertFalse("Assert 1.1: path absolute ", new File("\\\\\\a\b")
+ .isAbsolute());
+ }
// Test data used in a few places below
dirName = System.getProperty("user.dir");
@@ -226,10 +231,13 @@
assertEquals("wrong result 1", ref1.getPath(), file1.getPath());
File file2 = new File("/", "//dir1/file1");
assertEquals("wrong result 2", ref1.getPath(), file2.getPath());
- File file3 = new File("\\", "\\dir1\\file1");
- assertEquals("wrong result 3", ref1.getPath(), file3.getPath());
- File file4 = new File("\\", "\\\\dir1\\file1");
- assertEquals("wrong result 4", ref1.getPath(), file4.getPath());
+
+ if (File.separatorChar == '\\') {
+ File file3 = new File("\\", "\\dir1\\file1");
+ assertEquals("wrong result 3", ref1.getPath(), file3.getPath());
+ File file4 = new File("\\", "\\\\dir1\\file1");
+ assertEquals("wrong result 4", ref1.getPath(), file4.getPath());
+ }
File ref2 = new File("/lib/content-types.properties");
File file5 = new File("/", "lib/content-types.properties");
@@ -247,10 +255,13 @@
assertEquals("wrong result 1", ref1.getPath(), file1.getPath());
File file2 = new File(root, "//dir1/file1");
assertEquals("wrong result 2", ref1.getPath(), file2.getPath());
- File file3 = new File(root, "\\dir1\\file1");
- assertEquals("wrong result 3", ref1.getPath(), file3.getPath());
- File file4 = new File(root, "\\\\dir1\\file1");
- assertEquals("wrong result 4", ref1.getPath(), file4.getPath());
+
+ if (File.separatorChar == '\\') {
+ File file3 = new File(root, "\\dir1\\file1");
+ assertEquals("wrong result 3", ref1.getPath(), file3.getPath());
+ File file4 = new File(root, "\\\\dir1\\file1");
+ assertEquals("wrong result 4", ref1.getPath(), file4.getPath());
+ }
File ref2 = new File("/lib/content-types.properties");
File file5 = new File(root, "lib/content-types.properties");
@@ -700,14 +711,16 @@
new FileOutputStream(f1).close(); // create the file
if (f1.equals(f2)) {
try {
- new FileInputStream(f2);
+ FileInputStream fis = new FileInputStream(f2);
+ fis.close();
} catch (IOException e) {
fail("File system is case sensitive");
}
} else {
boolean exception = false;
try {
- new FileInputStream(f2);
+ FileInputStream fis = new FileInputStream(f2);
+ fis.close();
} catch (IOException e) {
exception = true;
}
@@ -1094,7 +1107,9 @@
|| (!f.isAbsolute() && f1.isAbsolute()));
} else {
File f = new File("/test");
+ File f1 = new File("\\test");
assertTrue("Absolute returned false", f.isAbsolute());
+ assertFalse("Absolute returned true", f1.isAbsolute());
}
assertTrue("Non-Absolute returned true", !new File("../test")
.isAbsolute());
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java Wed Nov 26 21:10:32 2008
@@ -111,7 +111,7 @@
public static class A1 implements Serializable {
- static final long serialVersionUID = 5942584913446079661L;
+ private static final long serialVersionUID = 5942584913446079661L;
B1 b1 = new B1();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java Wed Nov 26 21:10:32 2008
@@ -17,6 +17,7 @@
package org.apache.harmony.luni.tests.java.io;
+import java.io.File;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
@@ -24,6 +25,8 @@
import java.io.ObjectStreamClass;
import java.io.ObjectStreamField;
import java.io.Serializable;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.lang.reflect.Proxy;
import junit.framework.TestCase;
@@ -49,8 +52,8 @@
// Need to test during serialization to be sure an instance is
// returned
ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
- assertTrue("forClass returned an object: " + osc.forClass(), osc
- .forClass().equals(DummyClass.class));
+ assertEquals("forClass returned an object: " + osc.forClass(),
+ DummyClass.class, osc.forClass());
}
/**
@@ -80,12 +83,10 @@
*/
public void test_getName() {
ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
- assertTrue(
+ assertEquals(
"getName returned incorrect name: " + osc.getName(),
- osc
- .getName()
- .equals(
- "org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass"));
+ "org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass",
+ osc.getName());
}
/**
@@ -99,6 +100,68 @@
.getUID());
}
+ static class SyntheticTest implements Serializable {
+ private int i;
+
+ private class X implements Serializable {
+ public int get() {
+ return i;
+ }
+ }
+
+ public X foo() {
+ return new X();
+ }
+ }
+
+ /**
+ * @tests java.io.ObjectStreamClass#getSerialVersionUID()
+ */
+ public void test_getSerialVersionUID_inner_private_class() {
+ ObjectStreamClass osc1 = ObjectStreamClass.lookup(SyntheticTest.class);
+ assertEquals("SyntheticTest unexpected UID: "
+ + osc1.getSerialVersionUID(), -7784078941584535183L, osc1
+ .getSerialVersionUID());
+
+ ObjectStreamClass osc2 = ObjectStreamClass
+ .lookup(SyntheticTest.X.class);
+ assertEquals("SyntheticTest.X unexpected UID: "
+ + osc2.getSerialVersionUID(), -7703000075736397332L, osc2
+ .getSerialVersionUID());
+ }
+
+ /**
+ * @tests java.io.ObjectStreamClass#getSerialVersionUID()
+ */
+ public void test_getSerialVersionUID_classloader() throws Exception {
+ File file = new File(
+ "src/test/resources/org/apache/harmony/luni/tests/ObjectStreamClassTest.jar");
+ ClassLoader loader = new URLClassLoader(new URL[] { file.toURL() },
+ null);
+ Class cl1 = Class.forName("Test1$TestVarArgs", false, loader);
+ ObjectStreamClass osc1 = ObjectStreamClass.lookup(cl1);
+ assertEquals("Test1$TestVarArgs unexpected UID: "
+ + osc1.getSerialVersionUID(), -6051121963037986215L, osc1
+ .getSerialVersionUID());
+
+ Class cl2 = Class.forName("Test1$TestBridge", false, loader);
+ ObjectStreamClass osc2 = ObjectStreamClass.lookup(cl2);
+ assertEquals("Test1$TestBridge unexpected UID: "
+ + osc2.getSerialVersionUID(), 568585976855071180L, osc2
+ .getSerialVersionUID());
+ }
+
+ /**
+ * @tests java.io.ObjectStreamClass#lookup(java.lang.Class)
+ */
+ public void test_lookupLjava_lang_Class() {
+ ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+ assertEquals(
+ "lookup returned wrong class: " + osc.getName(),
+ "org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass",
+ osc.getName());
+ }
+
/**
* @tests java.io.ObjectStreamClass#toString()
*/
@@ -111,20 +174,6 @@
assertTrue("toString returned incorrect string: " + osc.toString(),
oscString.indexOf("serialVersionUID") >= 0
&& oscString.indexOf("999999999999999L") >= 0);
- ;
- }
-
- /**
- * @tests java.io.ObjectStreamClass#lookup(java.lang.Class)
- */
- public void test_lookupLjava_lang_Class() {
- ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
- assertTrue(
- "lookup returned wrong class: " + osc.getName(),
- osc
- .getName()
- .equals(
- "org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass"));
}
public void testSerialization() {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/OutputStreamWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/OutputStreamWriterTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/OutputStreamWriterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/OutputStreamWriterTest.java Wed Nov 26 21:10:32 2008
@@ -411,6 +411,7 @@
}
File f = File.createTempFile("one", "by_one");
+ f.deleteOnExit();
FileWriter fw = new FileWriter(f);
fw.write(strChars);
fw.close();
@@ -432,6 +433,7 @@
String inputStr = new String(bytes);
int len = inputStr.length();
File f = File.createTempFile("FileWriterBugTest ", null); //$NON-NLS-1$
+ f.deleteOnExit();
FileWriter writer = new FileWriter(f);
writer.write(inputStr);
writer.close();
@@ -442,7 +444,6 @@
int outCount = reader.read(outChars);
String outStr = new String(outChars, 0, outCount);
- f.deleteOnExit();
assertEquals(len, flen);
assertEquals(inputStr, outStr);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java Wed Nov 26 21:10:32 2008
@@ -118,6 +118,7 @@
raf.write(fileString.getBytes(), 0, 1000);
assertEquals("Incorrect filePointer returned", 1000, raf
.getFilePointer());
+ raf.close();
}
/**
@@ -129,6 +130,7 @@
raf.write(fileString.getBytes());
assertEquals("Incorrect length returned", fileString.length(), raf
.length());
+ raf.close();
}
/**
@@ -143,6 +145,7 @@
RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "r");
assertEquals("Incorrect bytes returned from read",
fileString.charAt(0), raf.read());
+ raf.close();
}
/**
@@ -159,7 +162,7 @@
raf.read(rbuf);
assertEquals("Incorrect bytes returned from read", fileString,
new String(rbuf, 0, fileString.length()));
-
+ raf.close();
}
/**
@@ -175,6 +178,7 @@
raf.read(rbuf, 0, fileString.length());
assertEquals("Incorrect bytes returned from read", fileString,
new String(rbuf, 0, fileString.length()));
+ raf.close();
}
/**
@@ -271,6 +275,7 @@
raf.readFully(buf, 0, buf.length);
fail("Reading past end of buffer did not throw EOFException");
} catch (EOFException e) {}
+ raf.close();
}
/**
@@ -299,6 +304,8 @@
assertEquals("Goodbye", raf.readLine());
assertEquals("Cruel", raf.readLine());
assertEquals("World", raf.readLine());
+
+ raf.close();
}
/**
@@ -374,6 +381,7 @@
raf.write(fileString.getBytes(), 0, fileString.length());
raf.seek(12);
assertEquals("Seek failed to set filePointer", 12, raf.getFilePointer());
+ raf.close();
}
/**
@@ -431,6 +439,7 @@
fis.read(rbuf, 0, fileString.length());
assertEquals("Incorrect bytes written", fileString, new String(rbuf, 0,
fileString.length()));
+ fis.close();
}
/**
@@ -447,6 +456,7 @@
fis.read(rbuf, 0, fileString.length());
assertEquals("Incorrect bytes written", fileString, new String(rbuf, 0,
fileString.length()));
+ fis.close();
}
/**
@@ -601,6 +611,7 @@
FileInputStream fis = new java.io.FileInputStream(fileName);
fis.read(rbuf, 0, 1);
assertEquals("Incorrect byte written", 't', rbuf[0]);
+ fis.close();
}
/**
@@ -762,6 +773,7 @@
fail("IOException must be thrown if pos < 0");
} catch (IOException e) {
}
+ raf.close();
}
/**
@@ -857,8 +869,9 @@
* @tests java.io.RandomAccessFile#read(byte[],int,int)
*/
public void test_read_$BII_NullPointerException() throws IOException {
- RandomAccessFile raf = new RandomAccessFile(File.createTempFile("tmp",
- "tmp"), "r");
+ File f = File.createTempFile("tmp", "tmp");
+ f.deleteOnExit();
+ RandomAccessFile raf = new RandomAccessFile(f, "r");
byte[] rbuf = null;
try {
raf.read(rbuf, 0, -1);
@@ -866,6 +879,7 @@
} catch (NullPointerException e) {
// expected
}
+ raf.close();
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.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/StringBuilderTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.java Wed Nov 26 21:10:32 2008
@@ -1553,27 +1553,118 @@
assertEquals("12XXX7",buffer.toString());
}
+ private void reverseTest(String org, String rev, String back) {
+ // create non-shared StringBuilder
+ StringBuilder sb = new StringBuilder(org);
+ sb.reverse();
+ String reversed = sb.toString();
+ assertEquals(rev, reversed);
+ // create non-shared StringBuilder
+ sb = new StringBuilder(reversed);
+ sb.reverse();
+ reversed = sb.toString();
+ assertEquals(back, reversed);
+
+ // test algorithm when StringBuilder is shared
+ sb = new StringBuilder(org);
+ String copy = sb.toString();
+ assertEquals(org, copy);
+ sb.reverse();
+ reversed = sb.toString();
+ assertEquals(rev, reversed);
+ sb = new StringBuilder(reversed);
+ copy = sb.toString();
+ assertEquals(rev, copy);
+ sb.reverse();
+ reversed = sb.toString();
+ assertEquals(back, reversed);
+ }
+
/**
* @tests java.lang.StringBuilder.reverse()
*/
public void test_reverse() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.reverse());
- assertEquals("9876543210", sb.toString());
+ final String fixture = "0123456789";
+ StringBuilder sb = new StringBuilder(fixture);
+ assertSame(sb, sb.reverse());
+ assertEquals("9876543210", sb.toString());
- sb = new StringBuilder("012345678");
- assertSame(sb, sb.reverse());
- assertEquals("876543210", sb.toString());
-
- sb.setLength(1);
- assertSame(sb, sb.reverse());
- assertEquals("8", sb.toString());
+ sb = new StringBuilder("012345678");
+ assertSame(sb, sb.reverse());
+ assertEquals("876543210", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.reverse());
- assertEquals("", sb.toString());
- }
+ sb.setLength(1);
+ assertSame(sb, sb.reverse());
+ assertEquals("8", sb.toString());
+
+ sb.setLength(0);
+ assertSame(sb, sb.reverse());
+ assertEquals("", sb.toString());
+
+ String str;
+ str = "a";
+ reverseTest(str, str, str);
+
+ str = "ab";
+ reverseTest(str, "ba", str);
+
+ str = "abcdef";
+ reverseTest(str, "fedcba", str);
+
+ str = "abcdefg";
+ reverseTest(str, "gfedcba", str);
+
+ str = "\ud800\udc00";
+ reverseTest(str, str, str);
+
+ str = "\udc00\ud800";
+ reverseTest(str, "\ud800\udc00", "\ud800\udc00");
+
+ str = "a\ud800\udc00";
+ reverseTest(str, "\ud800\udc00a", str);
+
+ str = "ab\ud800\udc00";
+ reverseTest(str, "\ud800\udc00ba", str);
+
+ str = "abc\ud800\udc00";
+ reverseTest(str, "\ud800\udc00cba", str);
+
+ str = "\ud800\udc00\udc01\ud801\ud802\udc02";
+ reverseTest(str, "\ud802\udc02\ud801\udc01\ud800\udc00",
+ "\ud800\udc00\ud801\udc01\ud802\udc02");
+
+ str = "\ud800\udc00\ud801\udc01\ud802\udc02";
+ reverseTest(str, "\ud802\udc02\ud801\udc01\ud800\udc00", str);
+
+ str = "\ud800\udc00\udc01\ud801a";
+ reverseTest(str, "a\ud801\udc01\ud800\udc00",
+ "\ud800\udc00\ud801\udc01a");
+
+ str = "a\ud800\udc00\ud801\udc01";
+ reverseTest(str, "\ud801\udc01\ud800\udc00a", str);
+
+ str = "\ud800\udc00\udc01\ud801ab";
+ reverseTest(str, "ba\ud801\udc01\ud800\udc00",
+ "\ud800\udc00\ud801\udc01ab");
+
+ str = "ab\ud800\udc00\ud801\udc01";
+ reverseTest(str, "\ud801\udc01\ud800\udc00ba", str);
+
+ str = "\ud800\udc00\ud801\udc01";
+ reverseTest(str, "\ud801\udc01\ud800\udc00", str);
+
+ str = "a\ud800\udc00z\ud801\udc01";
+ reverseTest(str, "\ud801\udc01z\ud800\udc00a", str);
+
+ str = "a\ud800\udc00bz\ud801\udc01";
+ reverseTest(str, "\ud801\udc01zb\ud800\udc00a", str);
+
+ str = "abc\ud802\udc02\ud801\udc01\ud800\udc00";
+ reverseTest(str, "\ud800\udc00\ud801\udc01\ud802\udc02cba", str);
+
+ str = "abcd\ud802\udc02\ud801\udc01\ud800\udc00";
+ reverseTest(str, "\ud800\udc00\ud801\udc01\ud802\udc02dcba", str);
+ }
/**
* @tests java.lang.StringBuilder.setCharAt(int, char)
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ConstructorTest.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/reflect/ConstructorTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ConstructorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ConstructorTest.java Wed Nov 26 21:10:32 2008
@@ -18,7 +18,9 @@
package org.apache.harmony.luni.tests.java.lang.reflect;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
+import java.util.Vector;
public class ConstructorTest extends junit.framework.TestCase {
@@ -175,6 +177,78 @@
assertEquals("improper instance created", 99, test.check());
}
+
+ /**
+ * @tests java.lang.reflect.Constructor#newInstance(java.lang.Object[])
+ */
+ public void test_newInstance_IAE() throws Exception {
+ Constructor constructor = Vector.class
+ .getConstructor(new Class[] { Integer.TYPE });
+
+ try {
+ constructor.newInstance(new Object[] { null });
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+ }
+
+ public void test_newInstance_InvocationTargetException() throws Exception {
+ Constructor constructor = MockObject.class.getConstructor(Class.class);
+
+ try {
+ constructor.newInstance(InvocationTargetException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ constructor.newInstance(IllegalAccessException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ constructor.newInstance(IllegalArgumentException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ constructor.newInstance(InvocationTargetException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ constructor.newInstance(Throwable.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+ }
+
+ static class MockObject {
+
+ public MockObject(Class<?> clazz) throws Exception {
+ if (clazz == InstantiationException.class) {
+ throw new InstantiationException();
+ } else if (clazz == IllegalAccessException.class) {
+ throw new IllegalAccessException();
+ } else if (clazz == IllegalArgumentException.class) {
+ throw new IllegalArgumentException();
+ } else if (clazz == InvocationTargetException.class) {
+ throw new InvocationTargetException(new Throwable());
+ } else {
+ throw new Exception();
+ }
+ }
+
+ }
/**
* @tests java.lang.reflect.Constructor#toString()
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/MethodTest.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/reflect/MethodTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/MethodTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/MethodTest.java Wed Nov 26 21:10:32 2008
@@ -394,7 +394,15 @@
ret = mth.invoke(new TestMethod(), new Object[0]);
} catch (InvocationTargetException e) {
// Correct behaviour
- }
+ }
+
+ mth = String.class.getMethod("valueOf", new Class[] { Integer.TYPE });
+ try {
+ mth.invoke(String.class, new Object[] { null });
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
TestMethod testMethod = new TestMethod();
Method methods[] = cl.getMethods();
@@ -533,6 +541,63 @@
}
}
}
+
+ public void test_invoke_InvocationTargetException() throws Exception {
+ Method method = MockObject.class.getDeclaredMethod("mockMethod", Class.class);
+ MockObject mockObject = new MockObject();
+
+ try {
+ method.invoke(mockObject, InvocationTargetException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ method.invoke(mockObject, IllegalAccessException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ method.invoke(mockObject, IllegalArgumentException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ method.invoke(mockObject, InvocationTargetException.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+
+ try {
+ method.invoke(mockObject, Throwable.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ // Expected
+ }
+ }
+
+ static class MockObject {
+
+ public void mockMethod (Class<?> clazz) throws Exception {
+ if (clazz == InstantiationException.class) {
+ throw new InstantiationException();
+ } else if (clazz == IllegalAccessException.class) {
+ throw new IllegalAccessException();
+ } else if (clazz == IllegalArgumentException.class) {
+ throw new IllegalArgumentException();
+ } else if (clazz == InvocationTargetException.class) {
+ throw new InvocationTargetException(new Throwable());
+ } else {
+ throw new Exception();
+ }
+ }
+ }
/**
* @tests java.lang.reflect.Method#toString()