You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2009/06/17 16:00:28 UTC
svn commit: r785606 [1/4] - in /harmony/enhanced/classlib/branches/java6: ./
make/ modules/archive/src/main/java/java/util/jar/
modules/archive/src/main/java/java/util/zip/
modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/
m...
Author: hindessm
Date: Wed Jun 17 14:00:24 2009
New Revision: 785606
URL: http://svn.apache.org/viewvc?rev=785606&view=rev
Log:
Merge updates from classlib trunk@785553 since r782693
Added:
harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200Test.java
- copied unchanged from r785553, harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200Test.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java
harmony/enhanced/classlib/branches/java6/modules/nio/META-INF/services/
- copied from r785527, harmony/enhanced/classlib/trunk/modules/nio/META-INF/services/
harmony/enhanced/classlib/branches/java6/modules/nio/META-INF/services/java.nio.channels.spi.SelectorProvider
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/nio/META-INF/services/java.nio.channels.spi.SelectorProvider
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CanonicalCodecFamilies.java
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CanonicalCodecFamilies.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttribute.java
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttribute.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/
- copied from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java (props changed)
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java (props changed)
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/NewAttributeBandsTest.java
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/NewAttributeBandsTest.java
harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/resources/Broken_entry.jar
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Broken_entry.jar
harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/resources/Broken_manifest.jar
- copied unchanged from r785527, harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Broken_manifest.jar
Removed:
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200Adapter.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200PackerAdapter.java
Modified:
harmony/enhanced/classlib/branches/java6/ (props changed)
harmony/enhanced/classlib/branches/java6/make/depends-common.xml (props changed)
harmony/enhanced/classlib/branches/java6/make/properties.xml
harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Pack200.java
harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java
harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java
harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java
harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLEncoder.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/ (props changed)
harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/locks/ (props changed)
harmony/enhanced/classlib/branches/java6/modules/jmx/META-INF/ (props changed)
harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java
harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/lang/management/MemoryUsageTest.java
harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging/ (props changed)
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/shared/MemMacros.h
harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ReadWriteDirectByteBuffer.java
harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/unix/exports.txt
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPConstant.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPDouble.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPFloat.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPInt.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPLong.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/BCIRenumberedAttribute.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPClass.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPConstant.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPNameAndType.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPUTF8.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200UnpackerAdapter.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ClassBandsTest.java
harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java (props changed)
harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java (props changed)
harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/text/parser/ (props changed)
harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormatSymbols.java
harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/SimpleDateFormat.java
harmony/enhanced/classlib/branches/java6/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
harmony/enhanced/classlib/branches/java6/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java
Propchange: harmony/enhanced/classlib/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk:713674-735919,765923-782693
+/harmony/enhanced/classlib/trunk:713674-735919,765923-785553
Propchange: harmony/enhanced/classlib/branches/java6/make/depends-common.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/make/depends-common.xml:768152-782693
+/harmony/enhanced/classlib/trunk/make/depends-common.xml:768152-785553
Modified: harmony/enhanced/classlib/branches/java6/make/properties.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/make/properties.xml?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/make/properties.xml (original)
+++ harmony/enhanced/classlib/branches/java6/make/properties.xml Wed Jun 17 14:00:24 2009
@@ -240,6 +240,7 @@
<or>
<isset property="is.aix"/>
<isset property="is.freebsd"/>
+ <isset property="is.zos"/>
</or>
</condition>
<property name="make.command" value="make" />
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Pack200.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Pack200.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Pack200.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Pack200.java Wed Jun 17 14:00:24 2009
@@ -57,7 +57,7 @@
public Object run() {
String className = System
.getProperty(SYSTEM_PROPERTY_PACKER,
- "org.apache.harmony.archive.internal.pack200.Pack200PackerAdapter"); //$NON-NLS-1$
+ "org.apache.harmony.pack200.Pack200PackerAdapter"); //$NON-NLS-1$
try {
// TODO Not sure if this will cause problems with
// loading the packer
@@ -87,7 +87,7 @@
public Object run() {
String className = System
.getProperty(SYSTEM_PROPERTY_UNPACKER,
- "org.apache.harmony.archive.internal.pack200.Pack200UnpackerAdapter");//$NON-NLS-1$
+ "org.apache.harmony.unpack200.Pack200UnpackerAdapter");//$NON-NLS-1$
try {
return ClassLoader.getSystemClassLoader()
.loadClass(className).newInstance();
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java Wed Jun 17 14:00:24 2009
@@ -47,7 +47,7 @@
private boolean finished; // Set by the inflateImpl native
- private boolean gotFirstByte = false;
+ private boolean gotFirstHeaderByte;
int inLength;
@@ -78,6 +78,7 @@
*/
public Inflater(boolean noHeader) {
streamHandle = createStream(noHeader);
+ gotFirstHeaderByte = noHeader;
}
private native long createStream(boolean noHeader1);
@@ -395,9 +396,9 @@
throw new ArrayIndexOutOfBoundsException();
}
- if (!gotFirstByte && nbytes > 0) {
- pass_magic_number_check = (buf[off] == MAGIC_NUMBER || nbytes > 1);
- gotFirstByte = true;
+ if (!gotFirstHeaderByte && nbytes > 0) {
+ pass_magic_number_check = (buf[off] == MAGIC_NUMBER);
+ gotFirstHeaderByte = true;
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java Wed Jun 17 14:00:24 2009
@@ -120,8 +120,24 @@
return;
}
}
+
+ /*
+ * The following code is careful to leave the ZipInputStream in a
+ * consistent state, even when close() results in an exception. It does
+ * so by:
+ * - pushing bytes back into the source stream
+ * - reading a data descriptor footer from the source stream
+ * - resetting fields that manage the entry being closed
+ */
+
// Ensure all entry bytes are read
- skip(Long.MAX_VALUE);
+ Exception failure = null;
+ try {
+ skip(Long.MAX_VALUE);
+ } catch (Exception e) {
+ failure = e;
+ }
+
int inB, out;
if (currentEntry.compressionMethod == DEFLATED) {
inB = inf.getTotalIn();
@@ -130,12 +146,38 @@
inB = inRead;
out = inRead;
}
- int diff = 0;
+ int diff = entryIn - inB;
// Pushback any required bytes
- if ((diff = entryIn - inB) != 0) {
+ if (diff != 0) {
((PushbackInputStream) in).unread(buf, len - diff, diff);
}
+ try {
+ readAndVerifyDataDescriptor(inB, out);
+ } catch (Exception e) {
+ if (failure == null) { // otherwise we're already going to throw
+ failure = e;
+ }
+ }
+
+ inf.reset();
+ lastRead = inRead = entryIn = len = 0;
+ crc.reset();
+ currentEntry = null;
+
+ if (failure != null) {
+ if (failure instanceof IOException) {
+ throw (IOException) failure;
+ } else if (failure instanceof RuntimeException) {
+ throw (RuntimeException) failure;
+ }
+ AssertionError error = new AssertionError();
+ error.initCause(failure);
+ throw error;
+ }
+ }
+
+ private void readAndVerifyDataDescriptor(int inB, int out) throws IOException {
if (hasDD) {
in.read(hdrBuf, 0, EXTHDR);
if (getLong(hdrBuf, 0) != EXTSIG) {
@@ -151,26 +193,19 @@
if (currentEntry.compressedSize != inB || currentEntry.size != out) {
throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$
}
-
- inf.reset();
- lastRead = inRead = entryIn = len = 0;
- crc.reset();
- currentEntry = null;
}
/**
- * Reads the next entry from this {@code ZipInputStream}.
+ * Reads the next entry from this {@code ZipInputStream} or {@code null} if
+ * no more entries are present.
*
* @return the next {@code ZipEntry} contained in the input stream.
* @throws IOException
- * if the stream is not positioned at the beginning of an entry
- * or if an other {@code IOException} occurs.
+ * if an {@code IOException} occurs.
* @see ZipEntry
*/
public ZipEntry getNextEntry() throws IOException {
- if (currentEntry != null) {
- closeEntry();
- }
+ closeEntry();
if (entriesEnd) {
return null;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java Wed Jun 17 14:00:24 2009
@@ -42,6 +42,7 @@
suite.addTestSuite(JarInputStreamTest.class);
suite.addTestSuite(JarOutputStreamTest.class);
suite.addTestSuite(ManifestTest.class);
+ suite.addTestSuite(Pack200Test.class);
suite.addTestSuite(ZipExecTest.class);
// $JUnit-END$
return suite;
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java Wed Jun 17 14:00:24 2009
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.HashSet;
@@ -26,6 +27,7 @@
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
import tests.support.resource.Support_Resources;
@@ -69,6 +71,61 @@
assertTrue("The jar input stream does not contain the correct entries", hasCorrectEntry);
}
+ public void test_closeAfterException() throws Exception {
+ File resources = Support_Resources.createTempFolder();
+ Support_Resources.copyFile(resources, null, "Broken_entry.jar");
+ InputStream is = Support_Resources.getStream("Broken_entry.jar");
+ JarInputStream jis = new JarInputStream(is, false);
+ jis.getNextEntry();
+ try {
+ jis.getNextEntry();
+ fail("ZipException expected");
+ } catch (ZipException ee) {
+ // expected
+ }
+ jis.close();
+ try {
+ jis.getNextEntry();
+ fail("IOException expected");
+ } catch (IOException ee) {
+ // expected
+ }
+ }
+
+ public void test_getNextJarEntry_Ex() throws Exception {
+ final Set<String> desired = new HashSet<String>(Arrays
+ .asList("foo/", "foo/bar/", "foo/bar/A.class", "Blah.txt"));
+ Set<String> actual = new HashSet<String>();
+ InputStream is = new URL(jarName).openConnection().getInputStream();
+ JarInputStream jis = new JarInputStream(is);
+ JarEntry je = jis.getNextJarEntry();
+ while (je != null) {
+ actual.add(je.toString());
+ je = jis.getNextJarEntry();
+ }
+ assertEquals(actual, desired);
+ jis.close();
+
+ try {
+ jis.getNextJarEntry();
+ fail("IOException expected");
+ } catch (IOException ee) {
+ // expected
+ }
+
+ File resources = Support_Resources.createTempFolder();
+ Support_Resources.copyFile(resources, null, "Broken_entry.jar");
+ is = Support_Resources.getStream("Broken_entry.jar");
+ jis = new JarInputStream(is, false);
+ jis.getNextJarEntry();
+ try {
+ jis.getNextJarEntry();
+ fail("ZipException expected");
+ } catch (ZipException ee) {
+ // expected
+ }
+ }
+
/**
* @tests java.util.jar.JarInputStream#getManifest()
*/
@@ -153,25 +210,17 @@
InputStream is = new URL(modJarName).openConnection()
.getInputStream();
JarInputStream jin = new JarInputStream(is, true);
- ZipEntry zipEntry = null;
- final int indexofDSA = 2;
- final int totalEntries = 4;
- int count = 0;
- while (count == 0 || zipEntry != null) {
- count++;
- try {
- zipEntry = jin.getNextEntry();
- if (count == indexofDSA + 1) {
- fail("Should throw Security Exception");
- }
- } catch (SecurityException e) {
- if (count != indexofDSA + 1) {
- throw e;
- }
- }
+ assertEquals("META-INF/TESTROOT.SF", jin.getNextEntry().getName());
+ assertEquals("META-INF/TESTROOT.DSA", jin.getNextEntry().getName());
+ try {
+ jin.getNextEntry();
+ fail();
+ } catch (SecurityException expected) {
}
- assertEquals(totalEntries + 2, count);
+ assertEquals("META-INF/", jin.getNextEntry().getName());
+ assertEquals("Test.class", jin.getNextEntry().getName());
+ assertNull(jin.getNextEntry());
jin.close();
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java Wed Jun 17 14:00:24 2009
@@ -185,6 +185,19 @@
"This is also text", new String(buf, 0, r));
}
+ public void test_getEntryLjava_lang_String_Ex() throws IOException {
+ java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
+ assertNotNull("Could not obtain ZipEntry", zentry);
+
+ zfile.close();
+ try {
+ zfile.getEntry("File2.txt");
+ fail("IllegalStateException expected");
+ } catch (IllegalStateException ee) {
+ // expected
+ }
+ }
+
/**
* @tests java.util.zip.ZipFile#getInputStream(java.util.zip.ZipEntry)
*/
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java Wed Jun 17 14:00:24 2009
@@ -18,9 +18,13 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -110,6 +114,32 @@
zis.closeEntry();
}
+ public void test_closeAfterException() throws Exception {
+ File resources = Support_Resources.createTempFolder();
+ Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
+ FileInputStream fis = new FileInputStream(new File(resources,
+ "Broken_manifest.jar"));
+
+ ZipInputStream zis1 = new ZipInputStream(fis);
+
+ try {
+ for (int i = 0; i < 6; i++) {
+ zis1.getNextEntry();
+ }
+ fail("ZipException expected");
+ } catch (ZipException ee) {
+ // expected
+ }
+
+ zis1.close();
+ try {
+ zis1.getNextEntry();
+ fail("IOException expected");
+ } catch (IOException ee) {
+ // expected
+ }
+ }
+
/**
* @tests java.util.zip.ZipInputStream#getNextEntry()
*/
@@ -128,6 +158,26 @@
assertEquals("Failed to read entry", 12, r);
}
+ public void testReadOneByteAtATime() throws IOException {
+ InputStream in = new FilterInputStream(Support_Resources.getStream("hyts_ZipFile.zip")) {
+ @Override
+ public int read(byte[] buffer, int offset, int count) throws IOException {
+ return super.read(buffer, offset, 1); // one byte at a time
+ }
+
+ @Override
+ public int read(byte[] buffer) throws IOException {
+ return super.read(buffer, 0, 1); // one byte at a time
+ }
+ };
+
+ zis = new ZipInputStream(in);
+ while ((zentry = zis.getNextEntry()) != null) {
+ zentry.getName();
+ }
+ zis.close();
+ }
+
/**
* @tests java.util.zip.ZipInputStream#skip(long)
*/
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventSetDescriptor.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventSetDescriptor.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventSetDescriptor.java Wed Jun 17 14:00:24 2009
@@ -177,7 +177,6 @@
this.listenerMethodDescriptors = new ArrayList<MethodDescriptor>();
for (MethodDescriptor element : listenerMethodDescriptors) {
- element.getMethod();
this.listenerMethodDescriptors.add(element);
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java Wed Jun 17 14:00:24 2009
@@ -529,6 +529,8 @@
private int readObjIndex = 0;
+ private SAXHandler saxHandler = null;
+
/**
* Create a decoder to read from specified input stream.
*
@@ -616,11 +618,14 @@
*/
@SuppressWarnings("nls")
public Object readObject() {
- try {
- SAXParserFactory.newInstance().newSAXParser().parse(inputStream,
- new SAXHandler());
- } catch (Exception e) {
- this.listener.exceptionThrown(e);
+ if (saxHandler == null) {
+ saxHandler = new SAXHandler();
+ try {
+ SAXParserFactory.newInstance().newSAXParser().parse(
+ inputStream, saxHandler);
+ } catch (Exception e) {
+ this.listener.exceptionThrown(e);
+ }
}
if (readObjIndex >= readObjs.size()) {
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLEncoder.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLEncoder.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLEncoder.java Wed Jun 17 14:00:24 2009
@@ -866,6 +866,9 @@
*/
@Override
public void writeExpression(Expression oldExp) {
+ if (null == oldExp) {
+ throw new NullPointerException();
+ }
boolean oldWritingObject = writingObject;
writingObject = true;
// get expression value
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java Wed Jun 17 14:00:24 2009
@@ -1277,7 +1277,24 @@
new EventSetDescriptor(OtherBean.class, "sample",
SampleListener.class, "fireSampleEvent");
}
-
+
+ public void test_EventSetDescriptor_Constructor() throws Exception {
+ EventSetDescriptor eventSetDescriptor = new EventSetDescriptor(
+ (String) null, (Class<?>) null, new MethodDescriptor[] { null,
+ null }, (Method) null, (Method) null);
+ assertNull(eventSetDescriptor.getName());
+ assertNull(eventSetDescriptor.getListenerType());
+ assertNull(eventSetDescriptor.getAddListenerMethod());
+ assertNull(eventSetDescriptor.getRemoveListenerMethod());
+
+ try {
+ eventSetDescriptor.getListenerMethods();
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
//Regression Test
public void testConstructor_withLackRemoveActionBean() throws Exception {
try {
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java Wed Jun 17 14:00:24 2009
@@ -430,6 +430,25 @@
assertEquals(o2, t2.getV());
}
+ public void testReadObject_Repeated() throws Exception {
+ final Vector<Exception> exceptionList = new Vector<Exception>();
+
+ final ExceptionListener exceptionListener = new ExceptionListener() {
+ public void exceptionThrown(Exception e) {
+ exceptionList.addElement(e);
+ }
+ };
+
+ XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
+ xml123bytes));
+ xmlDecoder.setExceptionListener(exceptionListener);
+ assertEquals(new Integer(1), xmlDecoder.readObject());
+ assertEquals(new Integer(2), xmlDecoder.readObject());
+ assertEquals(new Integer(3), xmlDecoder.readObject());
+ xmlDecoder.close();
+ assertEquals(0, exceptionList.size());
+ }
+
public void testSetExceptionListener_Called() throws Exception {
class MockExceptionListener implements ExceptionListener {
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java Wed Jun 17 14:00:24 2009
@@ -30,6 +30,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.Map;
@@ -200,8 +201,24 @@
return str;
}
- public void testWriteExpression() {
- // covered by testWriteObject
+ public void testWriteExpression_Scenario1() {
+ XMLEncoder xmlEncoder = new XMLEncoder((OutputStream) null);
+ try {
+ xmlEncoder.writeExpression((Expression) null);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testWriteExpression_Scenario2() {
+ XMLEncoder xmlEncoder = new XMLEncoder(new ByteArrayOutputStream());
+ try {
+ xmlEncoder.writeExpression((Expression) null);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
}
public void testWriteStatement() {
Propchange: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/atomic:765923-782693
+/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/atomic:765923-785553
Propchange: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/locks/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/locks:765923-782693
+/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/locks:765923-785553
Propchange: harmony/enhanced/classlib/branches/java6/modules/jmx/META-INF/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-782693
+/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-785553
Modified: harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java Wed Jun 17 14:00:24 2009
@@ -19,6 +19,8 @@
import javax.management.openmbean.CompositeData;
+import org.apache.harmony.lang.management.ManagementUtils;
+
/**
* <p>
* A memory usage snapshot.
@@ -28,6 +30,14 @@
*/
public class MemoryUsage {
+ private final long init;
+
+ private final long used;
+
+ private final long committed;
+
+ private final long max;
+
/**
* <p>
* Constructs a MemoryUsage object from the CompositeData passed.
@@ -42,26 +52,21 @@
if (cd == null) {
return null;
}
- try {
- long init = ((Long) cd.get("init")).longValue();
- long used = ((Long) cd.get("used")).longValue();
- long committed = ((Long) cd.get("committed")).longValue();
- long max = ((Long) cd.get("max")).longValue();
- return new MemoryUsage(init, used, committed, max);
- } catch (ClassCastException e) {
- // if any cast fails, then a type was incorrect
- throw new IllegalArgumentException(e);
- }
+ ManagementUtils.verifyFieldNumber(cd, 4);
+ String[] attributeNames = { "init", "used", "committed", "max" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ ManagementUtils.verifyFieldNames(cd, attributeNames);
+ String longClassName = "java.lang.Long"; //$NON-NLS-1$
+ String[] attributeTypes = { longClassName, longClassName,
+ longClassName, longClassName };
+ ManagementUtils.verifyFieldTypes(cd, attributeNames, attributeTypes);
+
+ long init = ((Long) cd.get("init")).longValue();
+ long used = ((Long) cd.get("used")).longValue();
+ long committed = ((Long) cd.get("committed")).longValue();
+ long max = ((Long) cd.get("max")).longValue();
+ return new MemoryUsage(init, used, committed, max);
}
- private final long init;
-
- private final long used;
-
- private final long committed;
-
- private final long max;
-
/**
* <p>
* Constructs a new MemoryUsage instance.
Modified: harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/lang/management/MemoryUsageTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/lang/management/MemoryUsageTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/lang/management/MemoryUsageTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/lang/management/MemoryUsageTest.java Wed Jun 17 14:00:24 2009
@@ -17,6 +17,7 @@
package org.apache.harmony.lang.management.tests.java.lang.management;
+import java.lang.management.MemoryNotificationInfo;
import java.lang.management.MemoryUsage;
import javax.management.openmbean.CompositeData;
@@ -29,6 +30,9 @@
public class MemoryUsageTest extends TestCase {
+ private static final String CLASS_NAME = MemoryNotificationInfo.class
+ .getName();
+
public void testFrom() throws Exception {
String[] itemNames = { "init", "used", "committed", "max" };
Object[] items = { Long.valueOf(1024), Long.valueOf(2048), Long.valueOf(4096),
@@ -94,6 +98,138 @@
assertNull(MemoryUsage.from(null));
}
+ public void test_from_scenario1() throws Exception {
+ String[] names = { "init", "used", "committed", "max", "additionName" };
+ Object[] values = { 1024L, 2048L, 4096L, 8128L, "additionalValue" };
+ OpenType[] types = { SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG, SimpleType.STRING };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ MemoryUsage usage = MemoryUsage.from(data);
+ assertEquals(values[0], usage.getInit());
+ assertEquals(values[1], usage.getUsed());
+ assertEquals(values[2], usage.getCommitted());
+ assertEquals(values[3], usage.getMax());
+ }
+
+ public void test_from_scenario2() throws Exception {
+ String[] names = { "init", "used", "committed" };
+ Object[] values = { null, null, null };
+ OpenType[] types = { SimpleType.LONG, SimpleType.LONG, SimpleType.LONG };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ try {
+ MemoryUsage.from(data);
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+ }
+
+ public void test_from_scenario3() throws Exception {
+ String[] names = { "init", "used", "committed", "max" };
+ Object[] values = { null, 2048L, 4096L, 8128L };
+ OpenType[] types = { SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ try {
+ MemoryUsage.from(data);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void test_from_scenario4() throws Exception {
+ String[] names = { "init", "used", "committed", "max" };
+ Object[] values = { 1024L, null, 4096L, 8128L };
+ OpenType[] types = { SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ try {
+ MemoryUsage.from(data);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void test_from_scenario5() throws Exception {
+ String[] names = { "init", "used", "committed", "max" };
+ Object[] values = { 1024L, 2048L, null, 8128L };
+ OpenType[] types = { SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ try {
+ MemoryUsage.from(data);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void test_from_scenario6() throws Exception {
+ String[] names = { "init", "used", "committed", "max" };
+ Object[] values = { 1024L, 2048L, 4096L, null };
+ OpenType[] types = { SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ try {
+ MemoryUsage.from(data);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void test_from_scenario7() throws Exception {
+ String[] names = { "noninit", "used", "committed", "max" };
+ Object[] values = { 1024L, 2048L, 4096L, 8128L };
+ OpenType[] types = { SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ try {
+ MemoryUsage.from(data);
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+ }
+
+ public void test_from_scenario8() throws Exception {
+ String[] names = { "init", "used", "committed", "max" };
+ Object[] values = { "initValue", 2048L, 4096L, 8128L };
+ OpenType[] types = { SimpleType.STRING, SimpleType.LONG,
+ SimpleType.LONG, SimpleType.LONG };
+ CompositeType compositeType = getCompositeType(names, types);
+ CompositeData data = new CompositeDataSupport(compositeType, names,
+ values);
+ try {
+ MemoryUsage.from(data);
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+ }
+
+ protected CompositeType getCompositeType(String[] typeNames,
+ OpenType[] typeTypes) throws Exception {
+ return new CompositeType(CLASS_NAME, CLASS_NAME, typeNames, typeNames,
+ typeTypes);
+ }
+
public void testConstructor() {
try {
new MemoryUsage(-2, 2048, 4096, 8128);
Propchange: harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging:768152-782693
+/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging:768152-785553
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java Wed Jun 17 14:00:24 2009
@@ -360,7 +360,7 @@
return actionNames[SP_RESOLVE]; // If none specified return the
}
// implied action resolve
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
if ((actionsMask & SP_CONNECT) == SP_CONNECT) {
sb.append(',');
sb.append(actionNames[SP_CONNECT]);
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=785606&r1=785605&r2=785606&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 Jun 17 14:00:24 2009
@@ -73,10 +73,11 @@
* the collection of elements to add.
*/
public ArrayList(Collection<? extends E> collection) {
- int size = collection.size();
firstIndex = 0;
+ Object[] objects = collection.toArray();
+ int size = objects.length;
array = newElementArray(size + (size / 10));
- collection.toArray(array);
+ System.arraycopy(objects, 0, array, 0, size);
lastIndex = size;
modCount = 1;
}
@@ -173,7 +174,12 @@
if (this == collection) {
collection = (ArrayList)clone();
}
- int growSize = collection.size();
+ Object[] dumparray = collection.toArray();
+ int growSize = dumparray.length;
+ if (growSize == 0) {
+ return false;
+ }
+
if (0 < location && location < size) {
if (array.length - size < growSize) {
growForInsert(location, growSize);
@@ -205,15 +211,10 @@
lastIndex += growSize;
}
- if (growSize > 0) {
- Object[] dumparray = new Object[growSize];
- collection.toArray(dumparray);
- System.arraycopy(dumparray, 0, this.array, location + firstIndex,
- growSize);
- modCount++;
- return true;
- }
- return false;
+ System.arraycopy(dumparray, 0, this.array, location + firstIndex,
+ growSize);
+ modCount++;
+ return true;
}
/**
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=785606&r1=785605&r2=785606&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 Jun 17 14:00:24 2009
@@ -58,7 +58,7 @@
PROTOTYPE ((HyPortLibrary * portLibrary, int argc, char **argv, UDATA handle,
jint version, jboolean ignoreUnrecognized, char *mainClass,
UDATA classArg, char *propertiesFileName,
- int isStandaloneJar, char *vmdllsubdir));
+ int isStandaloneJar, char *vmdllsubdir, int versionFlag));
static int createVMArgs
PROTOTYPE ((HyPortLibrary * portLibrary, int argc, char **argv,
jint version, jboolean ignoreUnrecognized,
@@ -139,7 +139,6 @@
char defaultDllName[] = "harmonyvm";
char defaultDirName[] = "default";
int rc = -1;
- int showVersion = 0;
int versionFlag = 0;
int vmHelp = 0;
int genericLauncher = 0;
@@ -227,12 +226,13 @@
/* The arg is a JAR file to run */
isStandaloneJar = 1;
}
- if (0 == strcmp ("-version", argv[i])) {
- versionFlag = 1;
+ if (0 == strncmp ("-version", argv[i], 8)) {
+ /* Display version information */
+ versionFlag = i;
}
- if (0 == strcmp ("-showversion", argv[i])) {
+ if (0 == strncmp ("-showversion", argv[i], 12)) {
/* We are being asked to print our version and continue */
- showVersion = 1;
+ if (!versionFlag) versionFlag = i;
}
if ('-' != argv[i][0]) {
/* This is the main class */
@@ -353,22 +353,7 @@
}
#endif /* ! HY_NO_THR */
- if (showVersion == 1)
- {
- if (!versionWritten)
- {
- hyfile_printf (PORTLIB, HYPORT_TTY_OUT, HY_COPYRIGHT_STRING "\n");
- copyrightWritten = 1;
- versionWritten = 1;
- }
- }
- if (versionFlag == 1) {
- /*
- * We are being asked to print our version, and quit
- */
- hyfile_printf (PORTLIB, HYPORT_TTY_OUT, HY_COPYRIGHT_STRING "\n");
- }
/* set up the properties file */
propertiesFileName = hymem_allocate_memory (strlen (vmiPath) + 12);
if (propertiesFileName == NULL)
@@ -392,7 +377,7 @@
/* main launcher processing in this function */
rc = invocation
(PORTLIB, argc, argv, handle, JNI_VERSION_1_4, JNI_TRUE, mainClass,
- classArg, propertiesFileName, isStandaloneJar, vmdllsubdir);
+ classArg, propertiesFileName, isStandaloneJar, vmdllsubdir, versionFlag);
if (rc)
{
/* Print an error message except in the case where an uncaught Exception
@@ -642,7 +627,7 @@
invocation (HyPortLibrary * portLibrary, int argc, char **argv, UDATA handle,
jint version, jboolean ignoreUnrecognized, char *mainClass,
UDATA classArg, char *propertiesFileName,
- int isStandaloneJar, char *vmdllsubdir)
+ int isStandaloneJar, char *vmdllsubdir, int versionFlag)
{
JavaVMInitArgs vm_args;
JavaVM *jvm;
@@ -678,6 +663,32 @@
}
rc = 0;
+
+ if (versionFlag) {
+ jclass clazz;
+ jmethodID mID;
+ jstring jStrObject;
+
+ /* First, print the copyright string to stdout */
+ hyfile_printf (PORTLIB, HYPORT_TTY_OUT, HY_COPYRIGHT_STRING "\n");
+
+ jStrObject = (*env)->NewStringUTF (env, argv[versionFlag]);
+ if (!jStrObject) return 3;
+
+ clazz = (*env)->FindClass (env, "org/apache/harmony/luni/util/Version");
+ if (!clazz) return 3;
+
+ mID = (*env)->GetStaticMethodID (env, clazz, "version",
+ "(Ljava/lang/String;)V");
+ if (!mID) return 3;
+
+ (*env)->CallStaticVoidMethod(env, clazz, mID, jStrObject);
+
+ /* if -version is specified, exit, otherwise continue */
+ if (0 == strncmp ("-version", argv[versionFlag], 8))
+ return 0;
+ }
+
if (mainClass)
{
if (isStandaloneJar)
@@ -952,7 +963,9 @@
{
if ( (strcmp (argv[i], "-jar") != 0)
&& (strncmp (argv[i], "-vmdir:", 7) != 0)
- && (strncmp (argv[i], "-vm:", 4) != 0) )
+ && (strncmp (argv[i], "-vm:", 4) != 0)
+ && (strncmp (argv[i], "-version", 8) != 0)
+ && (strncmp (argv[i], "-showversion", 12) != 0))
{
/* special coding for -classpath and -cp */
/* they get passed to the vm as -Djava.class.path */
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt Wed Jun 17 14:00:24 2009
@@ -54,26 +54,6 @@
Java_java_io_File_setWritableImpl
Java_java_io_FileDescriptor_oneTimeInitialization
Java_java_io_FileDescriptor_syncImpl
-Java_java_io_FileDescriptor_valid
-Java_java_io_ObjectInputStream_newInstance
-Java_java_io_ObjectInputStream_objSetField
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2B
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2C
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2D
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2F
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2I
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2J
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2S
-Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2Z
-Java_java_io_ObjectOutputStream_getFieldBool
-Java_java_io_ObjectOutputStream_getFieldByte
-Java_java_io_ObjectOutputStream_getFieldChar
-Java_java_io_ObjectOutputStream_getFieldDouble
-Java_java_io_ObjectOutputStream_getFieldFloat
-Java_java_io_ObjectOutputStream_getFieldInt
-Java_java_io_ObjectOutputStream_getFieldLong
-Java_java_io_ObjectOutputStream_getFieldObj
-Java_java_io_ObjectOutputStream_getFieldShort
Java_java_io_ObjectStreamClass_getConstructorSignature
Java_java_io_ObjectStreamClass_getFieldSignature
Java_java_io_ObjectStreamClass_getMethodSignature
@@ -213,7 +193,6 @@
Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind
Java_org_apache_harmony_luni_platform_OSNetworkSystem_listenStreamSocket
Java_org_apache_harmony_luni_platform_OSNetworkSystem_availableStream
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_accept
Java_org_apache_harmony_luni_platform_OSNetworkSystem_supportsUrgentData
Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendUrgentData
Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectDatagram
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.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/ArrayListTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java Wed Jun 17 14:00:24 2009
@@ -86,6 +86,12 @@
}
+ public void testConstructorWithConcurrentCollection() {
+ Collection<String> collection = shrinksOnSize("A", "B", "C", "D");
+ ArrayList<String> list = new ArrayList<String>(collection);
+ assertFalse(list.contains(null));
+ }
+
/**
* @tests java.util.ArrayList#add(int, java.lang.Object)
*/
@@ -866,6 +872,20 @@
assertEquals(14, list.size());
}
+ public void testAddAllWithConcurrentCollection() {
+ ArrayList<String> list = new ArrayList<String>();
+ list.addAll(shrinksOnSize("A", "B", "C", "D"));
+ assertFalse(list.contains(null));
+ }
+
+ public void testAddAllAtPositionWithConcurrentCollection() {
+ ArrayList<String> list = new ArrayList<String>(
+ Arrays.asList("A", "B", "C", "D"));
+
+ list.addAll(3, shrinksOnSize("E", "F", "G", "H"));
+ assertFalse(list.contains(null));
+ }
+
public void test_override_size() throws Exception {
ArrayList testlist = new MockArrayList();
// though size is overriden, it should passed without exception
@@ -927,4 +947,31 @@
for (int i = 0; i < objArray.length; i++)
alist.add(objArray[i]);
}
+
+ /**
+ * Returns a collection that emulates another thread calling remove() each
+ * time the current thread calls size().
+ */
+ private <T> Collection<T> shrinksOnSize(T... elements) {
+ return new HashSet<T>(Arrays.asList(elements)) {
+ boolean shrink = true;
+
+ @Override
+ public int size() {
+ int result = super.size();
+ if (shrink) {
+ Iterator<T> i = iterator();
+ i.next();
+ i.remove();
+ }
+ return result;
+ }
+
+ @Override
+ public Object[] toArray() {
+ shrink = false;
+ return super.toArray();
+ }
+ };
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/shared/MemMacros.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/shared/MemMacros.h?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/shared/MemMacros.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/shared/MemMacros.h Wed Jun 17 14:00:24 2009
@@ -53,16 +53,7 @@
(((x) & 0x00000000000000ffull) << 56))
-#ifdef __linux__ /* linux section */
-
-/* linux ia32 section */
-#ifdef __i386__
-
-#define get_unaligned(type, ptr) ( *((type *)((uintptr_t)(ptr))) )
-#define set_unaligned(type, ptr, val) ( (void) (*((type *)((uintptr_t)(ptr))) = val) )
-
-/* linux ipf section*/
-#else
+#if defined(LINUX_X86_64) || defined(LINUX_IA64)
#include <string.h>
#define get_unaligned(type, ptr) \
@@ -78,12 +69,9 @@
(void)0; \
})
-#endif /* ifdef __i386__ */
-
-/* windows section */
#else
#define get_unaligned(type, ptr) ( *((type *)((uintptr_t)(ptr))) )
#define set_unaligned(type, ptr, val) ( (void) (*((type *)((uintptr_t)(ptr))) = val) )
-#endif /* ifdef __linux__*/
+#endif
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ReadWriteDirectByteBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ReadWriteDirectByteBuffer.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ReadWriteDirectByteBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ReadWriteDirectByteBuffer.java Wed Jun 17 14:00:24 2009
@@ -117,9 +117,6 @@
if (len > remaining()) {
throw new BufferOverflowException();
}
- if (isReadOnly()) {
- throw new ReadOnlyBufferException();
- }
getBaseAddress().setByteArray(offset + position, src, off, len);
position += len;
return this;
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java Wed Jun 17 14:00:24 2009
@@ -392,8 +392,7 @@
if (!src.isOpen()) {
throw new ClosedChannelException();
}
- if (position < 0 || count < 0 || position > Integer.MAX_VALUE
- || count > Integer.MAX_VALUE) {
+ if (position < 0 || count < 0) {
throw new IllegalArgumentException();
}
if (position > size()) {
@@ -435,8 +434,7 @@
if (target instanceof ReadOnlyFileChannel) {
throw new NonWritableChannelException();
}
- if (position < 0 || count < 0 || position > Integer.MAX_VALUE
- || count > Integer.MAX_VALUE) {
+ if (position < 0 || count < 0) {
throw new IllegalArgumentException();
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/unix/exports.txt?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/unix/exports.txt (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/unix/exports.txt Wed Jun 17 14:00:24 2009
@@ -112,18 +112,10 @@
Java_org_apache_harmony_niochar_charset_additional_IBM870_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_IBM871_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_IBM871_00024Decoder_nDecode
- Java_org_apache_harmony_niochar_charset_additional_IBM874_00024Encoder_nEncode
- Java_org_apache_harmony_niochar_charset_additional_IBM874_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_IBM918_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_IBM918_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_IBM_1Thai_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_IBM_1Thai_00024Decoder_nDecode
- Java_org_apache_harmony_niochar_charset_additional_ISO_18859_110_00024Encoder_nEncode
- Java_org_apache_harmony_niochar_charset_additional_ISO_18859_110_00024Decoder_nDecode
- Java_org_apache_harmony_niochar_charset_additional_ISO_18859_114_00024Encoder_nEncode
- Java_org_apache_harmony_niochar_charset_additional_ISO_18859_114_00024Decoder_nDecode
- Java_org_apache_harmony_niochar_charset_additional_ISO_18859_116_00024Encoder_nEncode
- Java_org_apache_harmony_niochar_charset_additional_ISO_18859_116_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_ISO_18859_13_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_ISO_18859_13_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_ISO_18859_16_00024Encoder_nEncode
@@ -134,8 +126,6 @@
Java_org_apache_harmony_niochar_charset_additional_windows_11255_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_windows_11256_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_windows_11256_00024Decoder_nDecode
- Java_org_apache_harmony_niochar_charset_additional_windows_11258_00024Encoder_nEncode
- Java_org_apache_harmony_niochar_charset_additional_windows_11258_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM1006_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM1006_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM1025_00024Encoder_nEncode
@@ -156,6 +146,8 @@
Java_org_apache_harmony_niochar_charset_additional_x_1IBM737_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM856_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM856_00024Decoder_nDecode
+ Java_org_apache_harmony_niochar_charset_additional_x_1IBM874_00024Encoder_nEncode
+ Java_org_apache_harmony_niochar_charset_additional_x_1IBM874_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM875_00024Encoder_nEncode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM875_00024Decoder_nDecode
Java_org_apache_harmony_niochar_charset_additional_x_1IBM922_00024Encoder_nEncode
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=785606&r1=785605&r2=785606&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 Wed Jun 17 14:00:24 2009
@@ -32,34 +32,56 @@
import java.util.jar.Manifest;
import java.util.zip.GZIPOutputStream;
-import org.objectweb.asm.ClassReader;
-
/**
- *
+ * Archive is the main entry point to pack200 and represents a packed archive.
+ * An archive is constructed with either a JarInputStream and an output stream
+ * or a JarFile as input and an OutputStream. Options can be set, then
+ * <code>pack()</code> is called, to pack the Jar file into a pack200 archive.
*/
public class Archive {
private final JarInputStream inputStream;
private final OutputStream outputStream;
private JarFile jarFile;
- private long segmentLimit = 1000000;
private long currentSegmentSize;
- private boolean stripDebug;
- private int effort = 5;
+ private final PackingOptions options;
+ /**
+ * Creates an Archive with streams for the input and output.
+ *
+ * @param inputStream
+ * @param outputStream
+ * @param options - packing options (if null then defaults are used)
+ * @throws IOException
+ */
public Archive(JarInputStream inputStream, OutputStream outputStream,
- boolean gzip) throws IOException {
+ PackingOptions options) throws IOException {
this.inputStream = inputStream;
- if (gzip) {
+ if(options == null) { // use all defaults
+ options = new PackingOptions();
+ }
+ this.options = options;
+ if (options.isGzip()) {
outputStream = new GZIPOutputStream(outputStream);
}
this.outputStream = new BufferedOutputStream(outputStream);
}
+ /**
+ * Creates an Archive with the given input file and a stream for the output
+ *
+ * @param jarFile - the input file
+ * @param outputStream
+ * @param options - packing options (if null then defaults are used)
+ * @throws IOException
+ */
public Archive(JarFile jarFile, OutputStream outputStream,
- boolean gzip) throws IOException {
-
- if (gzip) {
+ PackingOptions options) throws IOException {
+ if(options == null) { // use all defaults
+ options = new PackingOptions();
+ }
+ this.options = options;
+ if (options.isGzip()) {
outputStream = new GZIPOutputStream(outputStream);
}
this.outputStream = new BufferedOutputStream(outputStream);
@@ -67,26 +89,21 @@
inputStream = null;
}
- public void setSegmentLimit(int limit) {
- segmentLimit = limit;
- }
-
- public void setEffort(int effort) {
- this.effort = effort;
- }
-
- public void stripDebugAttributes() {
- stripDebug = true;
- }
-
+ /**
+ * Pack the archive
+ * @throws Pack200Exception
+ * @throws IOException
+ */
public void pack() throws Pack200Exception, IOException {
List classes = new ArrayList();
List files = new ArrayList();
+ int effort = options.getEffort();
+ long segmentLimit = options.getSegmentLimit();
+
if(effort == 0) {
doZeroEffortPack();
} else {
-
if (inputStream != null) {
Manifest manifest = jarFile != null ? jarFile.getManifest()
: inputStream.getManifest();
@@ -109,7 +126,7 @@
if (!added) { // not added because segment has reached
// maximum size
if(classes.size() > 0 || files.size() > 0) {
- new Segment().pack(classes, files, outputStream, stripDebug, effort);
+ new Segment().pack(classes, files, outputStream, options);
classes = new ArrayList();
files = new ArrayList();
currentSegmentSize = 0;
@@ -118,7 +135,7 @@
}
} else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
// create a new segment for each class unless size = 0
- new Segment().pack(classes, files, outputStream, stripDebug, effort);
+ new Segment().pack(classes, files, outputStream, options);
classes = new ArrayList();
files = new ArrayList();
}
@@ -132,7 +149,7 @@
jarFile.getInputStream(jarEntry)), classes, files);
if (!added) { // not added because segment has reached maximum
// size
- new Segment().pack(classes, files, outputStream, stripDebug, effort);
+ new Segment().pack(classes, files, outputStream, options);
classes = new ArrayList();
files = new ArrayList();
currentSegmentSize = 0;
@@ -141,14 +158,14 @@
currentSegmentSize = 0; // ignore the size of the first entry for compatibility with the RI
} else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
// create a new segment for each class unless size = 0
- new Segment().pack(classes, files, outputStream, stripDebug, effort);
+ new Segment().pack(classes, files, outputStream, options);
classes = new ArrayList();
files = new ArrayList();
}
}
}
if(classes.size() > 0 || files.size() > 0) {
- new Segment().pack(classes, files, outputStream, stripDebug, effort);
+ new Segment().pack(classes, files, outputStream, options);
}
outputStream.close();
}
@@ -207,6 +224,7 @@
private boolean addJarEntry(JarEntry jarEntry, InputStream stream,
List javaClasses, List files) throws IOException, Pack200Exception {
+ long segmentLimit = options.getSegmentLimit();
String name = jarEntry.getName();
long size = jarEntry.getSize();
if (size > Integer.MAX_VALUE) {
@@ -232,7 +250,8 @@
throw new RuntimeException("Error reading from stream");
}
if (name.endsWith(".class")) {
- ClassReader classParser = new Pack200ClassReader(bytes);
+ Pack200ClassReader classParser = new Pack200ClassReader(bytes);
+ classParser.setFileName(name);
javaClasses.add(classParser);
bytes = new byte[0];
}
@@ -257,7 +276,7 @@
static class File {
private final String name;
- private final byte[] contents;
+ private byte[] contents;
private final long modtime;
public File(String name, byte[] contents, long modtime) {
@@ -281,6 +300,10 @@
public String toString() {
return name;
}
+
+ public void setContents(byte[] contents) {
+ this.contents = contents;
+ }
}
}