You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2009/01/20 06:47:41 UTC
svn commit: r735939 [2/5] - in /harmony/enhanced/classlib/branches/java6: ./
modules/auth/META-INF/ modules/beans/src/main/java/java/beans/
modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/
modules/beans/src/test/support/java/org/a...
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/VectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/VectorTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/VectorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/VectorTest.java Mon Jan 19 21:47:38 2009
@@ -89,6 +89,20 @@
grow.addElement("four");
assertEquals("Wrong size", 4, grow.size());
assertEquals("Wrong capacity", 6, grow.capacity());
+
+ Vector emptyVector = new Vector(0, 0);
+ emptyVector.addElement("one");
+ assertEquals("Wrong size", 1, emptyVector.size());
+ emptyVector.addElement("two");
+ emptyVector.addElement("three");
+ assertEquals("Wrong size", 3, emptyVector.size());
+
+ try {
+ Vector negativeVector = new Vector(-1, 0);
+ fail("Should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Excepted
+ }
}
/**
@@ -178,6 +192,20 @@
.get(51));
assertNull("Wrong element at position 52--wanted null",
tVector.get(52));
+
+ try {
+ v.addAll(0, null);
+ fail("Should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Excepted
+ }
+
+ try {
+ v.addAll(-1, null);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -209,6 +237,13 @@
.get(vSize + 1));
assertNull("Wrong element at last position--wanted null", tVector
.get(vSize + 2));
+
+ try {
+ v.addAll(null);
+ fail("Should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Excepted
+ }
}
/**
@@ -419,6 +454,33 @@
.capacity());
v = new Vector(100);
assertEquals("ensureCapacity reduced capacity", 100, v.capacity());
+
+ v.ensureCapacity(150);
+ assertEquals(
+ "ensuieCapacity failed to set to be twice the old capacity",
+ 200, v.capacity());
+
+ v = new Vector(9, -1);
+ v.ensureCapacity(20);
+ assertEquals("ensureCapacity failed to set to be minCapacity", 20, v
+ .capacity());
+ v.ensureCapacity(15);
+ assertEquals("ensureCapacity reduced capacity", 20, v.capacity());
+ v.ensureCapacity(35);
+ assertEquals(
+ "ensuieCapacity failed to set to be twice the old capacity",
+ 40, v.capacity());
+
+ v = new Vector(9, 4);
+ v.ensureCapacity(11);
+ assertEquals("ensureCapacity failed to set correct capacity", 13, v
+ .capacity());
+ v.ensureCapacity(5);
+ assertEquals("ensureCapacity reduced capacity", 13, v.capacity());
+ v.ensureCapacity(20);
+ assertEquals(
+ "ensuieCapacity failed to set to be twice the old capacity",
+ 20, v.capacity());
}
/**
@@ -436,6 +498,10 @@
assertTrue("c) Equal vectors returned false", tVector.equals(v));
tVector.removeElementAt(22);
assertTrue("d) UnEqual vectors returned true", !tVector.equals(v));
+ assertTrue("e) Equal vectors returned false", tVector.equals(tVector));
+ assertFalse("f) UnEqual vectors returned true", tVector
+ .equals(new Object()));
+ assertFalse("g) Unequal vectors returned true", tVector.equals(null));
}
/**
@@ -448,6 +514,14 @@
tVector.insertElementAt(null, 0);
assertNull("Returned incorrect firstElement--wanted null", tVector
.firstElement());
+
+ Vector v = new Vector();
+ try {
+ v.firstElement();
+ fail("Should throw NoSuchElementException");
+ } catch (NoSuchElementException e) {
+ // Excepted
+ }
}
/**
@@ -540,6 +614,34 @@
.equals(prevElement));
v.insertElementAt(null, 20);
assertNull("null not inserted", v.elementAt(20));
+
+ try {
+ tVector.insertElementAt("Inserted Element", -1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.insertElementAt(null, -1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.insertElementAt("Inserted Element", tVector.size() + 1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.insertElementAt(null, tVector.size() + 1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -594,6 +696,14 @@
tVector.addElement(null);
assertNull("Incorrect last element returned--wanted null", tVector
.lastElement());
+
+ Vector vector = new Vector();
+ try {
+ vector.lastElement();
+ fail("Should throw NoSuchElementException");
+ } catch (NoSuchElementException e) {
+ // Excepted
+ }
}
/**
@@ -661,18 +771,41 @@
*/
public void test_removeI() {
// Test for method java.lang.Object java.util.Vector.remove(int)
- tVector.remove(36);
- assertTrue("Contained element after remove", !tVector
+ Object removeElement = tVector.get(36);
+ Object result = tVector.remove(36);
+ assertFalse("Contained element after remove", tVector
.contains("Test 36"));
+ assertEquals("Should return the element that was removed",
+ removeElement, result);
assertEquals("Failed to decrement size after remove",
99, tVector.size());
tVector.add(20, null);
- tVector.remove(19);
+ removeElement = tVector.get(19);
+ result = tVector.remove(19);
assertNull("Didn't move null element over", tVector.get(19));
- tVector.remove(19);
+ assertEquals("Should return the element that was removed",
+ removeElement, result);
+ removeElement = tVector.get(19);
+ result = tVector.remove(19);
assertNotNull("Didn't remove null element", tVector.get(19));
+ assertEquals("Should return the element that was removed",
+ removeElement, result);
assertEquals("Failed to decrement size after removing null", 98, tVector
.size());
+
+ try {
+ tVector.remove(-1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.remove(tVector.size());
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -758,13 +891,86 @@
public void test_removeElementAtI() {
// Test for method void java.util.Vector.removeElementAt(int)
Vector v = vectorClone(tVector);
+ int size = v.size();
v.removeElementAt(50);
assertEquals("Failed to remove element", -1, v.indexOf("Test 50", 0));
+ assertEquals("Test 51", v.get(50));
+ assertEquals(size - 1, v.size());
+
tVector.insertElementAt(null, 60);
+ assertNull(tVector.get(60));
+ size = tVector.size();
tVector.removeElementAt(60);
assertNotNull("Element at 60 should not be null after removal", tVector
.elementAt(60));
+ assertEquals(size - 1, tVector.size());
+
+ try {
+ tVector.removeElementAt(-1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.removeElementAt(tVector.size());
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
}
+
+ /**
+ * @tests {@link java.util.Vector#removeRange(int, int)}
+ */
+ public void test_removeRange() {
+ MockVector myVector = new MockVector();
+ myVector.removeRange(0, 0);
+
+ try {
+ myVector.removeRange(0, 1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ int[] data = { 1, 2, 3, 4 };
+ for (int i = 0; i < data.length; i++) {
+ myVector.add(i, data[i]);
+ }
+
+ myVector.removeRange(0, 2);
+ assertEquals(data[2], myVector.get(0));
+ assertEquals(data[3], myVector.get(1));
+
+ try {
+ myVector.removeRange(-1, 1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ myVector.removeRange(0, -1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ myVector.removeRange(1, 0);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ myVector.removeRange(2, 1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+ }
/**
* @tests java.util.Vector#retainAll(java.util.Collection)
@@ -789,8 +995,47 @@
// Test for method java.lang.Object java.util.Vector.set(int,
// java.lang.Object)
Object o = new Object();
- tVector.set(23, o);
+ Object previous = tVector.get(23);
+ Object result = tVector.set(23, o);
+ assertEquals(
+ "Should return the element previously at the specified position",
+ previous, result);
assertTrue("Failed to set Object", tVector.get(23) == o);
+
+ previous = tVector.get(0);
+ result = tVector.set(0, null);
+ assertEquals(
+ "Should return the element previously at the specified position",
+ previous, result);
+ assertNull("Failed to set Object", tVector.get(0));
+
+ try {
+ tVector.set(-1, o);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.set(-1, null);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.set(tVector.size(), o);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ tVector.set(tVector.size(), null);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -803,6 +1048,37 @@
v.setElementAt("Inserted Element", 99);
assertEquals("Element not set", "Inserted Element", ((String) v.elementAt(99))
);
+
+ v.setElementAt(null, 0);
+ assertNull("Null element not set", v.elementAt(0));
+
+ try {
+ v.setElementAt("Inserted Element", -1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ v.setElementAt(null, -1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ v.setElementAt("Inserted Element", v.size());
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ v.setElementAt(null, v.size());
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -811,8 +1087,32 @@
public void test_setSizeI() {
// Test for method void java.util.Vector.setSize(int)
Vector v = vectorClone(tVector);
+ int oldSize = v.size();
+ Object preElement = v.get(10);
v.setSize(10);
assertEquals("Failed to set size", 10, v.size());
+ assertEquals(
+ "All components at index newSize and greater should be discarded",
+ -1, v.indexOf(preElement));
+ try {
+ v.get(oldSize - 1);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted;
+ }
+
+ oldSize = v.size();
+ v.setSize(20);
+ assertEquals("Failed to set size", 20, v.size());
+ for (int i = oldSize; i < v.size(); i++) {
+ assertNull(v.get(i));
+ }
+
+ try {
+ v.setSize(-1);
+ fail("Should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -983,6 +1283,10 @@
public synchronized int size() {
return 0;
}
+
+ public void removeRange(int start, int end) {
+ super.removeRange(start, end);
+ }
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/META-INF/MANIFEST.MF?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/META-INF/MANIFEST.MF Mon Jan 19 21:47:38 2009
@@ -19,6 +19,7 @@
java.nio.charset,
java.security,
java.util,
+ java.util.concurrent.atomic,
org.apache.harmony.kernel.vm,
org.apache.harmony.luni.net,
org.apache.harmony.luni.platform,
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java Mon Jan 19 21:47:38 2009
@@ -22,6 +22,7 @@
import java.nio.channels.Selector;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* Abstract class for selectors.
@@ -33,7 +34,7 @@
*
*/
public abstract class AbstractSelector extends Selector {
- private volatile boolean isOpen = true;
+ private final AtomicBoolean isOpen = new AtomicBoolean(true);
private SelectorProvider provider = null;
@@ -58,9 +59,8 @@
* @see java.nio.channels.Selector#close()
*/
@Override
- public synchronized final void close() throws IOException {
- if (isOpen) {
- isOpen = false;
+ public final void close() throws IOException {
+ if (isOpen.getAndSet(false)) {
implCloseSelector();
}
}
@@ -78,7 +78,7 @@
*/
@Override
public final boolean isOpen() {
- return isOpen;
+ return isOpen.get();
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java Mon Jan 19 21:47:38 2009
@@ -138,6 +138,7 @@
*/
@Override
protected void implCloseSelector() throws IOException {
+ wakeup();
synchronized (this) {
synchronized (keysSet) {
synchronized (selectedKeys) {
@@ -147,7 +148,6 @@
deregister((AbstractSelectionKey) sk);
}
}
- wakeup();
}
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java Mon Jan 19 21:47:38 2009
@@ -33,7 +33,6 @@
import org.objectweb.asm.ClassReader;
-
/**
*
*/
@@ -42,10 +41,13 @@
private final JarInputStream inputStream;
private final OutputStream outputStream;
private JarFile jarFile;
+ private long segmentLimit = 1000000;
+ private long currentSegmentSize;
- public Archive(JarInputStream inputStream, OutputStream outputStream, boolean gzip) throws IOException {
+ public Archive(JarInputStream inputStream, OutputStream outputStream,
+ boolean gzip) throws IOException {
this.inputStream = inputStream;
- if(gzip) {
+ if (gzip) {
outputStream = new GZIPOutputStream(outputStream);
}
this.outputStream = new BufferedOutputStream(outputStream);
@@ -57,52 +59,110 @@
inputStream = null;
}
+ public void setSegmentLimit(int limit) {
+ segmentLimit = limit;
+ }
+
public void pack() throws Pack200Exception, IOException {
List classes = new ArrayList();
List files = new ArrayList();
- List classNames = new ArrayList();
- List classModtimes = new ArrayList();
- Manifest manifest = jarFile != null ? jarFile.getManifest() : inputStream.getManifest();
- if(manifest!= null) {
+ Manifest manifest = jarFile != null ? jarFile.getManifest()
+ : inputStream.getManifest();
+ if (manifest != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
manifest.write(baos);
files.add(new File("META-INF/MANIFEST.MF", baos.toByteArray(), 0));
}
- if(inputStream != null) {
- while(inputStream.available() > 0) {
+ if (inputStream != null) {
+ while (inputStream.available() > 0) {
JarEntry jarEntry = inputStream.getNextJarEntry();
- if(jarEntry != null) {
- addJarEntry(jarEntry, new BufferedInputStream(inputStream), classes, files);
+ if (jarEntry != null) {
+ boolean added = addJarEntry(jarEntry,
+ new BufferedInputStream(inputStream), classes,
+ files);
+ if (!added) { // not added because segment has reached
+ // maximum size
+ new Segment().pack(classes, files, outputStream);
+ classes = new ArrayList();
+ files = new ArrayList();
+ currentSegmentSize = 0;
+ if (!addJarEntry(jarEntry, new BufferedInputStream(
+ inputStream), classes, files)) {
+ throw new Pack200Exception(
+ "Segment limit is too small for the files you are trying to pack");
+ }
+ } else if (segmentLimit == 0) {
+ // create a new segment for each class
+ new Segment().pack(classes, files, outputStream);
+ classes = new ArrayList();
+ files = new ArrayList();
+ }
}
}
} else {
Enumeration jarEntries = jarFile.entries();
- while(jarEntries.hasMoreElements()) {
+ while (jarEntries.hasMoreElements()) {
JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
- addJarEntry(jarEntry, new BufferedInputStream(jarFile.getInputStream(jarEntry)), classes, files);
+ boolean added = addJarEntry(jarEntry, new BufferedInputStream(
+ jarFile.getInputStream(jarEntry)), classes, files);
+ if (!added) { // not added because segment has reached maximum
+ // size
+ new Segment().pack(classes, files, outputStream);
+ classes = new ArrayList();
+ files = new ArrayList();
+ currentSegmentSize = 0;
+ if (!addJarEntry(jarEntry, new BufferedInputStream(jarFile
+ .getInputStream(jarEntry)), classes, files)) {
+ throw new Pack200Exception("Segment limit is too small");
+ }
+ } else if (segmentLimit == 0) {
+ // create a new segment for each class
+ new Segment().pack(classes, files, outputStream);
+ classes = new ArrayList();
+ files = new ArrayList();
+ }
}
}
- new Segment().pack(classes, files, outputStream); // TODO: Multiple segments
+ if(classes.size() > 0 || files.size() > 0) {
+ new Segment().pack(classes, files, outputStream);
+ }
outputStream.close();
}
- private void addJarEntry(JarEntry jarEntry, InputStream stream, List javaClasses, List files) throws IOException, Pack200Exception {
+ private boolean addJarEntry(JarEntry jarEntry, InputStream stream,
+ List javaClasses, List files) throws IOException, Pack200Exception {
String name = jarEntry.getName();
long size = jarEntry.getSize();
if (size > Integer.MAX_VALUE) {
throw new RuntimeException("Large Class!");
}
- byte[] bytes = new byte[(int)size];
+ if(segmentLimit != -1 && segmentLimit != 0) {
+ // -1 is a special case where only one segment is created and
+ // 0 is a special case where one segment is created for each file
+ int packedSize = name.endsWith(".class") ? estimatePackedSize(size)
+ : (int) size;
+ if (packedSize + currentSegmentSize > segmentLimit) {
+ return false;
+ } else {
+ currentSegmentSize += packedSize;
+ }
+ }
+ byte[] bytes = new byte[(int) size];
int read = stream.read(bytes);
- if(read != size) {
+ if (read != size) {
throw new RuntimeException("Error reading from stream");
}
- if(name.endsWith(".class")) {
+ if (name.endsWith(".class")) {
ClassReader classParser = new Pack200ClassReader(bytes);
javaClasses.add(classParser);
bytes = new byte[0];
}
files.add(new File(name, bytes, jarEntry.getTime()));
+ return true;
+ }
+
+ private int estimatePackedSize(long size) {
+ return (int) size; // TODO: try to match the RI as closely as possible
}
static class File {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java Mon Jan 19 21:47:38 2009
@@ -171,7 +171,7 @@
}
public boolean hasContent() {
- return T.size() > 0;
+ return type_RS.size() > 0;
}
public int numBackwardsCalls() {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java Mon Jan 19 21:47:38 2009
@@ -679,6 +679,7 @@
IcTuple[] icAll = icBands.getIcTuples();
for (int k = 0; k < icAll.length; k++) {
if (icAll[k].getC().equals(icTupleC)) {
+ icTupleF = icAll[k].getF();
icTupleC2 = icAll[k].getC2();
icTupleN = icAll[k].getN();
break;
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/.settings/org.eclipse.jdt.core.prefs?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/.settings/org.eclipse.jdt.core.prefs (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/.settings/org.eclipse.jdt.core.prefs Mon Jan 19 21:47:38 2009
@@ -1,7 +1,7 @@
-#Wed May 03 13:10:22 BST 2006
+#Thu Jan 01 21:30:21 CST 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java Mon Jan 19 21:47:38 2009
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.util.Collection;
import java.util.EventListener;
import java.util.EventObject;
import java.util.HashMap;
@@ -347,7 +348,7 @@
for (int i = 0; i < names.length; i++) {
result.add(names[i]);
}
- return result.toArray(new String[0]);
+ return result.toArray(new String[result.size()]);
}
}
@@ -733,10 +734,11 @@
cachedNode.put(childrenNames[i], child);
}
}
- AbstractPreferences[] children = cachedNode
- .values().toArray(new AbstractPreferences[0]);
- for (int i = 0; i < children.length; i++) {
- children[i].removeNodeImpl();
+
+ final Collection<AbstractPreferences> values = cachedNode.values();
+ final AbstractPreferences[] children = values.toArray(new AbstractPreferences[values.size()]);
+ for (AbstractPreferences child : children) {
+ child.removeNodeImpl();
}
removeNodeSpi();
isRemoved = true;
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java Mon Jan 19 21:47:38 2009
@@ -17,7 +17,6 @@
package java.util.prefs;
-
/**
* An exception to indicate that some error was encountered while accessing
* the backing store.
@@ -25,29 +24,26 @@
* @since 1.4
*/
public class BackingStoreException extends Exception {
-
+
private static final long serialVersionUID = 859796500401108469L;
-
- /**
- * Constructs a new <code>BackingStoreException</code> instance using an
- * exception message.
- *
- * @param s the exception message.
- */
- public BackingStoreException (String s) {
- super(s);
- }
- /**
- * Constructs a new <code>BackingStoreException</code> instance using a
- * nested <code>Throwable</code> instance.
- *
- * @param t the nested <code>Throwable</code> instance.
- */
- public BackingStoreException (Throwable t) {
- super(t);
- }
+ /**
+ * Constructs a new <code>BackingStoreException</code> instance using an
+ * exception message.
+ *
+ * @param s the exception message.
+ */
+ public BackingStoreException (String s) {
+ super(s);
+ }
+
+ /**
+ * Constructs a new <code>BackingStoreException</code> instance using a
+ * nested <code>Throwable</code> instance.
+ *
+ * @param t the nested <code>Throwable</code> instance.
+ */
+ public BackingStoreException (Throwable t) {
+ super(t);
+ }
}
-
-
-
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java Mon Jan 19 21:47:38 2009
@@ -97,7 +97,7 @@
* Constructors
* --------------------------------------------------------------
*/
-
+
/**
* Construct root <code>FilePreferencesImpl</code> instance, construct
* user root if userNode is true, system root otherwise
@@ -108,7 +108,7 @@
path = userNode ? USER_HOME : SYSTEM_HOME;
initPrefs();
}
-
+
/**
* Construct a prefs using given parent and given name
*/
@@ -132,16 +132,16 @@
@Override
protected String[] childrenNamesSpi() throws BackingStoreException {
String[] names = AccessController
- .doPrivileged(new PrivilegedAction<String[]>() {
- public String[] run() {
- return dir.list(new FilenameFilter() {
- public boolean accept(File parent, String name) {
- return new File(path + File.separator + name).isDirectory();
- }
- });
-
+ .doPrivileged(new PrivilegedAction<String[]>() {
+ public String[] run() {
+ return dir.list(new FilenameFilter() {
+ public boolean accept(File parent, String name) {
+ return new File(path + File.separator + name).isDirectory();
}
});
+
+ }
+ });
if (null == names) {// file is not a directory, exception case
// prefs.3=Cannot get children names for {0}!
throw new BackingStoreException(
@@ -199,7 +199,8 @@
@Override
protected String[] keysSpi() throws BackingStoreException {
- return prefs.keySet().toArray(new String[0]);
+ final Set<Object> ks = prefs.keySet();
+ return ks.toArray(new String[ks.size()]);
}
@Override
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/InvalidPreferencesFormatException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/InvalidPreferencesFormatException.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/InvalidPreferencesFormatException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/InvalidPreferencesFormatException.java Mon Jan 19 21:47:38 2009
@@ -27,40 +27,37 @@
* @since 1.4
*/
public class InvalidPreferencesFormatException extends Exception {
-
- private static final long serialVersionUID = -791715184232119669L;
-
- /**
- * Constructs a new <code>InvalidPreferencesFormatException</code> instance using an
- * exception message.
- *
- * @param s the exception message.
- */
- public InvalidPreferencesFormatException (String s) {
- super(s);
- }
-
- /**
- * Constructs a new <code>InvalidPreferencesFormatException</code> instance using a
- * exception message and a nested <code>Throwable</code> instance.
- *
- * @param s the exception message.
- * @param t the nested <code>Throwable</code> instance.
- */
- public InvalidPreferencesFormatException (String s, Throwable t) {
- super(s,t);
- }
- /**
- * Constructs a new <code>InvalidPreferencesFormatException</code> instance using a
- * nested <code>Throwable</code> instance.
- *
- * @param t the nested <code>Throwable</code> instance.
- */
- public InvalidPreferencesFormatException (Throwable t) {
- super(t);
- }
-}
+ private static final long serialVersionUID = -791715184232119669L;
+ /**
+ * Constructs a new <code>InvalidPreferencesFormatException</code> instance using an
+ * exception message.
+ *
+ * @param s the exception message.
+ */
+ public InvalidPreferencesFormatException (String s) {
+ super(s);
+ }
+ /**
+ * Constructs a new <code>InvalidPreferencesFormatException</code> instance using a
+ * exception message and a nested <code>Throwable</code> instance.
+ *
+ * @param s the exception message.
+ * @param t the nested <code>Throwable</code> instance.
+ */
+ public InvalidPreferencesFormatException (String s, Throwable t) {
+ super(s,t);
+ }
+ /**
+ * Constructs a new <code>InvalidPreferencesFormatException</code> instance using a
+ * nested <code>Throwable</code> instance.
+ *
+ * @param t the nested <code>Throwable</code> instance.
+ */
+ public InvalidPreferencesFormatException (Throwable t) {
+ super(t);
+ }
+}
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java Mon Jan 19 21:47:38 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.io.Serializable;
@@ -37,61 +36,56 @@
* @since 1.4
*/
public class NodeChangeEvent extends EventObject implements Serializable {
-
+
private static final long serialVersionUID = 8068949086596572957L;
-
+
private final Preferences parent;
private final Preferences child;
-
+
/**
* Construct a new <code>NodeChangeEvent</code> instance.
*
- * @param p the <code>Preferences</code> instance that this event happened,
- * this object is considered as event's source.
- * @param c the child <code>Preferences</code> instance that was added
- * or deleted.
+ * @param p the <code>Preferences</code> instance that this event happened, this object is
+ * considered as event's source.
+ * @param c the child <code>Preferences</code> instance that was added or deleted.
+ */
+ public NodeChangeEvent (Preferences p, Preferences c) {
+ super(p);
+ parent = p;
+ child = c;
+ }
+
+ /**
+ * Get the <code>Preferences</code> instance that this event happened.
+ *
+ * @return the <code>Preferences</code> instance that this event happened.
*/
- public NodeChangeEvent (Preferences p, Preferences c) {
- super(p);
- parent = p;
- child = c;
- }
-
- /**
- * Get the <code>Preferences</code> instance that this event happened.
- *
- * @return the <code>Preferences</code> instance that this event happened.
- */
- public Preferences getParent() {
- return parent;
- }
-
- /**
- * Get the child <code>Preferences</code> node that was added or removed.
- *
- * @return the child <code>Preferences</code> node that was added or removed.
- */
- public Preferences getChild() {
- return child;
- }
-
- /*
+ public Preferences getParent() {
+ return parent;
+ }
+
+ /**
+ * Get the child <code>Preferences</code> node that was added or removed.
+ *
+ * @return the child <code>Preferences</code> node that was added or removed.
+ */
+ public Preferences getChild() {
+ return child;
+ }
+
+ /**
* This method always throws a <code>NotSerializableException</code>, because
* this object cannot be serialized,
*/
- private void writeObject (ObjectOutputStream out) throws IOException {
- throw new NotSerializableException();
- }
-
- /*
+ private void writeObject (ObjectOutputStream out) throws IOException {
+ throw new NotSerializableException();
+ }
+
+ /**
* This method always throws a <code>NotSerializableException</code>, because
* this object cannot be serialized,
*/
- private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException {
- throw new NotSerializableException();
- }
+ private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new NotSerializableException();
+ }
}
-
-
-
-
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java Mon Jan 19 21:47:38 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.util.EventListener;
@@ -30,20 +29,17 @@
* @since 1.4
*/
public interface NodeChangeListener extends EventListener {
- /**
- * This method gets called whenever a child is added to a node.
- *
- * @param e Node change event.
- */
- public void childAdded (NodeChangeEvent e);
-
- /**
- * This method gets called whenever a child is removed from a node.
- *
- * @param e Node change event.
- */
- public void childRemoved (NodeChangeEvent e);
+ /**
+ * This method gets called whenever a child is added to a node.
+ *
+ * @param e Node change event.
+ */
+ public void childAdded (NodeChangeEvent e);
+
+ /**
+ * This method gets called whenever a child is removed from a node.
+ *
+ * @param e Node change event.
+ */
+ public void childRemoved (NodeChangeEvent e);
}
-
-
-
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java Mon Jan 19 21:47:38 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.io.IOException;
@@ -40,7 +39,7 @@
public class PreferenceChangeEvent extends EventObject implements Serializable {
private static final long serialVersionUID = 793724513368024975L;
-
+
private final Preferences node;
private final String key;
@@ -50,11 +49,11 @@
/**
* Construct a new <code>PreferenceChangeEvent</code> instance.
*
- * @param p the <code>Preferences</code> instance that this event happened,
- * this object is considered as event's source.
- * @param k the changed preference's key
- * @param v the new value of the changed preference, this value can be null,
- * which means the preference is removed.
+ * @param p the <code>Preferences</code> instance that this event happened, this object is
+ * considered as event's source.
+ * @param k the changed preference's key
+ * @param v the new value of the changed preference, this value can be null, which means the
+ * preference is removed.
*/
public PreferenceChangeEvent(Preferences p, String k, String v) {
super(p);
@@ -92,7 +91,7 @@
return node;
}
- /*
+ /**
* This method always throws a <code>NotSerializableException</code>, because
* this object cannot be serialized,
*/
@@ -100,7 +99,7 @@
throw new NotSerializableException();
}
- /*
+ /**
* This method always throws a <code>NotSerializableException</code>, because
* this object cannot be serialized,
*/
@@ -108,5 +107,3 @@
throw new NotSerializableException();
}
}
-
-
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java Mon Jan 19 21:47:38 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.util.EventListener;
@@ -30,16 +29,12 @@
* @since 1.4
*/
public interface PreferenceChangeListener extends EventListener {
-
+
/**
- * This method gets invoked whenever some preference is added, deleted or
- * updated.
+ * This method gets invoked whenever some preference is added, deleted or updated.
*
- * @param pce the event instance which describes the changed Preferences
- * instance and preferences value.
+ * @param pce the event instance which describes the changed Preferences instance and
+ * preferences value.
*/
- void preferenceChange (PreferenceChangeEvent pce);
+ void preferenceChange (PreferenceChangeEvent pce);
}
-
-
-