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 2010/10/07 16:56:08 UTC
svn commit: r1005476 [1/2] - in /harmony/enhanced/java/branches/mrh: ./
classlib/ classlib/modules/archive/src/main/java/java/util/zip/
classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/
classlib/modules/beans/src/ma...
Author: hindessm
Date: Thu Oct 7 14:56:06 2010
New Revision: 1005476
URL: http://svn.apache.org/viewvc?rev=1005476&view=rev
Log:
Merge changes up to trunk@1005442.
Added:
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/harmony/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMISocketFactoryTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMISocketFactoryTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RemoteObjectTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RemoteObjectTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RemoteServerTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RemoteServerTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RemoteStubTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RemoteStubTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupIDTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupIDTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/dgc/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/dgc/
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/dgc/LeaseTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/dgc/LeaseTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/dgc/VMIDTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/dgc/VMIDTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/
- copied from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/ActivityCompletedExceptionTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/ActivityCompletedExceptionTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/ActivityRequiredExceptionTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/ActivityRequiredExceptionTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/InvalidActivityExceptionTest.java
- copied unchanged from r1005442, harmony/enhanced/java/trunk/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/javax/activity/InvalidActivityExceptionTest.java
Removed:
harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/ReferenceMap.java
harmony/enhanced/java/branches/mrh/classlib/modules/text/src/main/java/org/apache/harmony/text/BidiRun.java
Modified:
harmony/enhanced/java/branches/mrh/ (props changed)
harmony/enhanced/java/branches/mrh/build.xml
harmony/enhanced/java/branches/mrh/classlib/ (props changed)
harmony/enhanced/java/branches/mrh/classlib/LICENSE
harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java
harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java
harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/Encoder.java
harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/PersistenceDelegate.java
harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java
harmony/enhanced/java/branches/mrh/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java
harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/StringBuilder.java
harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/LogStreamTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/ServerNotActiveExceptionTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/security/src/main/java/common/java/security/Permissions.java
harmony/enhanced/java/branches/mrh/classlib/modules/text/make/exclude.common
harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/Support_Format.java
harmony/enhanced/java/branches/mrh/common_resources/ (props changed)
harmony/enhanced/java/branches/mrh/common_resources/make/depends.properties
harmony/enhanced/java/branches/mrh/common_resources/make/svn.xml
harmony/enhanced/java/branches/mrh/drlvm/ (props changed)
harmony/enhanced/java/branches/mrh/drlvm/make/properties.xml
harmony/enhanced/java/branches/mrh/jdktools/make/depends.properties
harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/META-INF/MANIFEST.MF
harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java
harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/samsa.c
harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/resources/data/javac.dat
Propchange: harmony/enhanced/java/branches/mrh/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 7 14:56:06 2010
@@ -1,2 +1,2 @@
/harmony/enhanced/java/branches/mrh:935751
-/harmony/enhanced/java/trunk:935751-1002080
+/harmony/enhanced/java/trunk:935751-1005442
Modified: harmony/enhanced/java/branches/mrh/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/build.xml?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/build.xml (original)
+++ harmony/enhanced/java/branches/mrh/build.xml Thu Oct 7 14:56:06 2010
@@ -174,16 +174,16 @@ Usage:
<!-- fetches external dependencies -->
<!-- ============================================================== -->
<target name="fetch-depends"
- description="Fetches dependencies. Note: Some of Harmony dependencies are licensed under terms other than the Apache License v2."
- depends="fetch-classlib-libs,
- fetch-vm-libs,
- fetch-jdktools-libs"/>
+ description="Fetches dependencies for all components. Note: Some of Harmony dependencies are licensed under terms other than the Apache License v2."
+ depends="fetch-depends-classlib,
+ fetch-depends-vm,
+ fetch-depends-jdktools"/>
<target name="check-depends"
- description="Checks dependencies."
- depends="check-classlib-libs,
- check-vm-libs,
- check-jdktools-libs"/>
+ description="Checks dependencies for all components."
+ depends="check-depends-classlib,
+ check-depends-vm,
+ check-depends-jdktools"/>
<target name="bundle-hdk-tgz" depends="init" if="is.unix">
@@ -474,7 +474,7 @@ Usage:
<target name="build-classlib"
depends="init,-init-hdk,-build-classlib,assemble-hdk-doc"/>
- <target name="-build-classlib" depends="auto-fetch-classlib-libs">
+ <target name="-build-classlib" depends="auto-fetch-depends-classlib">
<ant antfile="classlib/build.xml" target="build" inheritAll="false" >
<propertyset refid="required.props" />
<property name="svn.info" value="${harmony.long.version}"/>
@@ -494,8 +494,8 @@ Usage:
</delete>
</target>
- <target name="auto-fetch-classlib-libs" if="auto.fetch">
- <ant target="fetch-classlib-libs">
+ <target name="auto-fetch-depends-classlib" if="auto.fetch">
+ <ant target="fetch-depends-classlib">
<propertyset refid="required.props" />
<property name="svn.info" value="${harmony.long.version}"/>
<property name="svn.revision" value="${harmony.version}"/>
@@ -504,7 +504,8 @@ Usage:
</ant>
</target>
- <target name="fetch-classlib-libs">
+ <target name="fetch-depends-classlib"
+ description="Fetches dependencies for classlib. Note: Some of Harmony dependencies are licensed under terms other than the Apache License v2.">
<ant antfile="classlib/build.xml" target="fetch-depends"
inheritall="false" >
<propertyset refid="required.props" />
@@ -515,7 +516,8 @@ Usage:
</ant>
</target>
- <target name="check-classlib-libs">
+ <target name="check-depends-classlib"
+ description="Checks dependencies for classlib.">
<ant antfile="classlib/build.xml" target="check-depends"
inheritall="false" >
<propertyset refid="required.props" />
@@ -561,7 +563,7 @@ Usage:
<!-- ============================================================== -->
<!-- ensures that dependencies are up to date and then builds a vm -->
<!-- ============================================================== -->
- <target name="build-vm" depends="init,auto-fetch-vm-libs">
+ <target name="build-vm" depends="init,auto-fetch-depends-vm">
<ant antfile="${vm.dir.loc}/build.xml"
target="build" inheritAll="false" >
<propertyset refid="required.props" />
@@ -575,8 +577,8 @@ Usage:
</ant>
</target>
- <target name="auto-fetch-vm-libs" if="auto.fetch">
- <ant target="fetch-vm-libs">
+ <target name="auto-fetch-depends-vm" if="auto.fetch">
+ <ant target="fetch-depends-vm">
<propertyset refid="required.props" />
<property name="svn.info" value="${harmony.long.version}"/>
<property name="svn.revision" value="${harmony.version}"/>
@@ -585,7 +587,8 @@ Usage:
</ant>
</target>
- <target name="fetch-vm-libs">
+ <target name="fetch-depends-vm"
+ description="Fetches dependencies for the vm. Note: Some of Harmony dependencies are licensed under terms other than the Apache License v2.">
<ant antfile="${vm.dir.loc}/build.xml"
target="fetch-depends" inheritall="false" >
<propertyset refid="required.props" />
@@ -596,7 +599,8 @@ Usage:
</ant>
</target>
- <target name="check-vm-libs">
+ <target name="check-depends-vm"
+ description="Checks dependencies for the vm.">
<ant antfile="${vm.dir.loc}/build.xml"
target="check-depends" inheritall="false" >
<propertyset refid="required.props" />
@@ -625,7 +629,7 @@ Usage:
<!-- ensures dependencies are up to date, then builds jdktools -->
<!-- ============================================================== -->
<target name="build-jdktools"
- depends="init,-init-hdk,auto-fetch-jdktools-libs">
+ depends="init,-init-hdk,auto-fetch-depends-jdktools">
<ant antfile="jdktools/build.xml" target="build" inheritall="false" >
<propertyset refid="required.props" />
<property name="svn.info" value="${harmony.long.version}"/>
@@ -635,15 +639,16 @@ Usage:
</ant>
</target>
- <target name="auto-fetch-jdktools-libs" if="auto.fetch">
- <ant target="fetch-jdktools-libs" inheritall="false" >
+ <target name="auto-fetch-depends-jdktools" if="auto.fetch">
+ <ant target="fetch-depends-jdktools" inheritall="false" >
<propertyset refid="required.props" />
<property name="hy.target" location="${hy.target}"/>
<property name="common.resources" location="common_resources" />
</ant>
</target>
- <target name="fetch-jdktools-libs">
+ <target name="fetch-depends-jdktools"
+ description="Fetches dependencies for jdktools. Note: Some of Harmony dependencies are licensed under terms other than the Apache License v2.">
<ant antfile="jdktools/build.xml" target="fetch-depends"
inheritall="false" >
<propertyset refid="required.props" />
@@ -652,7 +657,8 @@ Usage:
</ant>
</target>
- <target name="check-jdktools-libs">
+ <target name="check-depends-jdktools"
+ description="Checks dependencies for jdktools">
<ant antfile="jdktools/build.xml" target="check-depends"
inheritall="false" >
<propertyset refid="required.props" />
Propchange: harmony/enhanced/java/branches/mrh/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 7 14:56:06 2010
@@ -1,4 +1,4 @@
/harmony/enhanced/classlib/trunk:926318-926838
/harmony/enhanced/java/branches/mrh/classlib:935751
-/harmony/enhanced/java/trunk/classlib:935751-1002080
+/harmony/enhanced/java/trunk/classlib:935751-1005442
/harmony/enhanced/trunk/classlib:476395-926317
Modified: harmony/enhanced/java/branches/mrh/classlib/LICENSE
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/LICENSE?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/LICENSE (original)
+++ harmony/enhanced/java/branches/mrh/classlib/LICENSE Thu Oct 7 14:56:06 2010
@@ -646,6 +646,8 @@ the licensing terms, the licenses are re
RFC 1779 - A String Representation of Distinguished Names
+RFC 2040 - The RC5, RC5-CBC, RC5-CBC-Pad, and RC5-CTS Algorithms
+
RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One: Format of
Internet Message Bodies
@@ -656,6 +658,9 @@ RFC 2253 - Lightweight Directory Access
Representation of Distinguished Names
Copyright (C) The Internet Society (1997). All Rights Reserved.
+RFC 2268 - A Description of the RC2(r) Encryption Algorithm
+ Copyright (C) The Internet Society (1998). All Rights Reserved.
+
RFC 2313 - PKCS #1: RSA Encryption
Copyright (C) The Internet Society (1998). All Rights Reserved.
@@ -674,6 +679,9 @@ RFC 2781 - UTF-16, an encoding of ISO 10
RFC 2891 - LDAP Control Extension for Server Side Sorting of Search Results
Copyright (C) The Internet Society (2000). All Rights Reserved.
+RFC 2898 - PKCS #5: Password-Based Cryptography Specification Version 2.0
+ Copyright (C) The Internet Society (2000). All Rights Reserved.
+
RFC 2985 - PKCS #9: Selected Object Classes and Attribute Types
Copyright (C) The Internet Society (2000). All Rights Reserved.
@@ -684,6 +692,13 @@ RFC 3280 - Internet X.509 Public Key Inf
Certificate Revocation List (CRL) Profile
Copyright (C) The Internet Society (2002). All Rights Reserved.
+RFC 3447 - Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography
+ Specifications Version 2.1
+ Copyright (C) The Internet Society (2003). All Rights Reserved.
+
+RFC 3629 - UTF-8, a transformation format of ISO 10646
+ Copyright (C) The Internet Society (2003). All Rights Reserved.
+
INTERNET-DRAFT - Persistent Search: A Simple LDAP Change Notification Mechanism
<draft-ietf-ldapext-psearch-03.txt>
Copyright (C) The Internet Society (1997-2000). All Rights Reserved.
@@ -723,13 +738,20 @@ the following IETF RFCs. Portions of th
included in source code comments for reference, and in accordance with
the licensing terms, the licenses are reproduced here:
+RFC 3961 - Encryption and Checksum Specifications for Kerberos 5
+ Copyright (C) The Internet Society (2005).
+
+RFC 4120 - The Kerberos Network Authentication Service (V5)
+ Copyright (C) The Internet Society (2005).
+
RFC 4122 - A Universally Unique Identifier (UUID) URN Namespace
Copyright (C) The Internet Society (2005).
+RFC 5208 - Public-Key Cryptography Standards (PKCS) #8:
+ Private-Key Information Syntax Specification Version 1.2
+ Copyright (C) The IETF Trust (2008).
-The following statement applies to this RFC:
-
- Copyright (C) The Internet Society (2005).
+The following statement applies to each RFC:
This document is subject to the rights, licenses and restrictions
contained in BCP 78, and except as set forth therein, the authors
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java Thu Oct 7 14:56:06 2010
@@ -236,10 +236,6 @@ public class Inflater {
throw new ArrayIndexOutOfBoundsException();
}
- if (nbytes == 0) {
- return 0;
- }
-
if (streamHandle == -1) {
throw new IllegalStateException();
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java Thu Oct 7 14:56:06 2010
@@ -17,13 +17,14 @@
package org.apache.harmony.archive.tests.java.util.zip;
import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.zip.Adler32;
import java.io.UnsupportedEncodingException;
+import java.util.zip.Adler32;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
import java.util.zip.Inflater;
import java.util.zip.ZipException;
@@ -448,6 +449,28 @@ public class InflaterTest extends junit.
infl2.end();
}
+ /*
+ * Regression test for HARMONY-6637
+ */
+ public void testInflateZero() throws Exception {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(
+ byteArrayOutputStream);
+ deflaterOutputStream.close();
+ byte[] input = byteArrayOutputStream.toByteArray();
+
+ Inflater inflater = new Inflater();
+ inflater.setInput(input);
+ byte[] buffer = new byte[0];
+ int numRead = 0;
+ while (!inflater.finished()) {
+ int inflatedChunkSize = inflater.inflate(buffer, numRead,
+ buffer.length - numRead);
+ numRead += inflatedChunkSize;
+ }
+ inflater.end();
+ }
+
/**
* @tests java.util.zip.Inflater#Inflater()
*/
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java Thu Oct 7 14:56:06 2010
@@ -115,22 +115,23 @@ public class DefaultPersistenceDelegate
return;
}
PropertyDescriptor[] pds = info.getPropertyDescriptors();
-
+ Method getter, setter;
// Initialize each found non-transient property
for (int i = 0; i < pds.length; i++) {
// Skip a property whose transient attribute is true
if (Boolean.TRUE.equals(pds[i].getValue("transient"))) { //$NON-NLS-1$
continue;
}
+ getter = pds[i].getReadMethod();
+ setter = pds[i].getWriteMethod();
// Skip a property having no setter or getter
- if (null == pds[i].getWriteMethod()
- || null == pds[i].getReadMethod()) {
+ if (getter == null || setter == null) {
continue;
}
// Get the value of the property in the old instance
- Expression getterExp = new Expression(oldInstance, pds[i]
- .getReadMethod().getName(), null);
+ Expression getterExp = new Expression(oldInstance,
+ getter.getName(), null);
try {
// Calculate the old value of the property
Object oldVal = getterExp.getValue();
@@ -138,30 +139,14 @@ public class DefaultPersistenceDelegate
enc.writeExpression(getterExp);
// Get the target value that exists in the new environment
Object targetVal = enc.get(oldVal);
- // Get the current property value in the new environment
- Object newVal = new Expression(newInstance, pds[i]
- .getReadMethod().getName(), null).getValue();
- /*
- * Make the target value and current property value equivalent
- * in the new environment
- */
- if (null == targetVal) {
- if (null != newVal) {
- // Set to null
- Statement setterStm = new Statement(oldInstance, pds[i]
- .getWriteMethod().getName(),
- new Object[] { null });
- enc.writeStatement(setterStm);
- }
- } else {
- PersistenceDelegate pd = enc
- .getPersistenceDelegate(targetVal.getClass());
- if (!pd.mutatesTo(targetVal, newVal)) {
- Statement setterStm = new Statement(oldInstance, pds[i]
- .getWriteMethod().getName(),
- new Object[] { oldVal });
- enc.writeStatement(setterStm);
- }
+ Object newVal = new Expression(newInstance, getter.getName(),
+ null).getValue();
+ boolean invokeSetter = targetVal == null ? (newVal != null && oldVal == null)
+ : !enc.getPersistenceDelegate(targetVal.getClass())
+ .mutatesTo(targetVal, newVal);
+ if (invokeSetter) {
+ enc.writeStatement(new Statement(oldInstance, setter
+ .getName(), new Object[] { oldVal }));
}
} catch (Exception ex) {
enc.getExceptionListener().exceptionThrown(ex);
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/Encoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/Encoder.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/Encoder.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/Encoder.java Thu Oct 7 14:56:06 2010
@@ -40,6 +40,7 @@ import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Date;
import java.util.Hashtable;
+import java.util.IdentityHashMap;
import java.util.Map;
import javax.swing.Box;
@@ -49,22 +50,21 @@ import javax.swing.JTabbedPane;
import javax.swing.ToolTipManager;
/**
- * The <code>Encoder</code>, together with <code>PersistenceDelegate</code>
- * s, can encode an object into a series of java statements. By executing these
+ * The <code>Encoder</code>, together with <code>PersistenceDelegate</code> s,
+ * can encode an object into a series of java statements. By executing these
* statements, a new object can be created and it will has the same state as the
* original object which has been passed to the encoder. Here "has the same
* state" means the two objects are indistinguishable from their public API.
* <p>
- * The <code>Encoder</code> and <code>PersistenceDelegate</code> s do this
- * by creating copies of the input object and all objects it references. The
- * copy process continues recursively util every object in the object graph has
- * its new copy and the new version has the same state as the old version. All
+ * The <code>Encoder</code> and <code>PersistenceDelegate</code> s do this by
+ * creating copies of the input object and all objects it references. The copy
+ * process continues recursively util every object in the object graph has its
+ * new copy and the new version has the same state as the old version. All
* statements used to create those new objects and executed on them during the
* process form the result of encoding.
* </p>
*
*/
-@SuppressWarnings("unchecked")
public class Encoder {
private static final Hashtable<Class<?>, PersistenceDelegate> delegates = new Hashtable<Class<?>, PersistenceDelegate>();
@@ -140,7 +140,7 @@ public class Encoder {
private ExceptionListener listener = defaultExListener;
- private ReferenceMap oldNewMap = new ReferenceMap();
+ private IdentityHashMap<Object, Object> oldNewMap = new IdentityHashMap<Object, Object>();
/**
* Construct a new encoder.
@@ -169,7 +169,7 @@ public class Encoder {
* one.
*/
public Object get(Object old) {
- if (old == null || old instanceof String) {
+ if (old == null || old.getClass() == String.class) {
return old;
}
return oldNewMap.get(old);
@@ -193,15 +193,14 @@ public class Encoder {
* <p>
* The <code>PersistenceDelegate</code> is determined as following:
* <ol>
- * <li>If a <code>PersistenceDelegate</code> has been registered by
- * calling <code>setPersistenceDelegate</code> for the given type, it is
- * returned.</li>
+ * <li>If a <code>PersistenceDelegate</code> has been registered by calling
+ * <code>setPersistenceDelegate</code> for the given type, it is returned.</li>
* <li>If the given type is an array class, a special
* <code>PersistenceDelegate</code> for array types is returned.</li>
* <li>If the given type is a proxy class, a special
* <code>PersistenceDelegate</code> for proxy classes is returned.</li>
- * <li><code>Introspector</code> is used to check the bean descriptor
- * value "persistenceDelegate". If one is set, it is returned.</li>
+ * <li><code>Introspector</code> is used to check the bean descriptor value
+ * "persistenceDelegate". If one is set, it is returned.</li>
* <li>If none of the above applies, the
* <code>DefaultPersistenceDelegate</code> is returned.</li>
* </ol>
@@ -260,12 +259,8 @@ public class Encoder {
return defaultPD;
}
- private void put(Object old, Object nu) {
- oldNewMap.put(old, nu);
- }
-
/**
- * Remvoe the existing new copy of the given old object.
+ * Remove the existing new copy of the given old object.
*
* @param old
* an old object
@@ -300,27 +295,40 @@ public class Encoder {
delegates.put(type, delegate);
}
- private Object forceNew(Object old) {
- if (old == null) {
+ Object expressionValue(Expression exp) {
+ try {
+ return exp == null ? null : exp.getValue();
+ } catch (IndexOutOfBoundsException e) {
return null;
+ } catch (Exception e) {
+ listener.exceptionThrown(new Exception(
+ "failed to excute expression: " + exp, e)); //$NON-NLS-1$
}
- Object nu = get(old);
- if (nu != null) {
- return nu;
- }
- writeObject(old);
- return get(old);
+ return null;
}
- private Object[] forceNewArray(Object[] oldArray) {
- if (oldArray == null) {
- return null;
+ private Statement createNewStatement(Statement oldStat) {
+ Object newTarget = createNewObject(oldStat.getTarget());
+ Object[] oldArgs = oldStat.getArguments();
+ Object[] newArgs = new Object[oldArgs.length];
+ for (int index = 0; index < oldArgs.length; index++) {
+ newArgs[index] = createNewObject(oldArgs[index]);
}
- Object newArray[] = new Object[oldArray.length];
- for (int i = 0; i < oldArray.length; i++) {
- newArray[i] = forceNew(oldArray[i]);
+
+ if (oldStat.getClass() == Expression.class) {
+ return new Expression(newTarget, oldStat.getMethodName(), newArgs);
+ } else {
+ return new Statement(newTarget, oldStat.getMethodName(), newArgs);
}
- return newArray;
+ }
+
+ private Object createNewObject(Object old) {
+ Object nu = get(old);
+ if (nu == null) {
+ writeObject(old);
+ nu = get(old);
+ }
+ return nu;
}
/**
@@ -353,30 +361,21 @@ public class Encoder {
throw new NullPointerException();
}
try {
- // if oldValue exists, noop
- Object oldValue = oldExp.getValue();
+ // if oldValue exists, no operation
+ Object oldValue = expressionValue(oldExp);
if (oldValue == null || get(oldValue) != null) {
return;
}
// copy to newExp
- Object newTarget = forceNew(oldExp.getTarget());
- Object newArgs[] = forceNewArray(oldExp.getArguments());
- Expression newExp = new Expression(newTarget, oldExp
- .getMethodName(), newArgs);
-
- // execute newExp
- Object newValue = null;
+ Expression newExp = (Expression) createNewStatement(oldExp);
+ // relate oldValue to newValue
try {
- newValue = newExp.getValue();
- } catch (IndexOutOfBoundsException ex) {
- // Current Container does not have any component, newVal set
- // to null
+ oldNewMap.put(oldValue, newExp.getValue());
+ } catch (IndexOutOfBoundsException e) {
+ // container does not have any component, set newVal null
}
- // relate oldValue to newValue
- put(oldValue, newValue);
-
// force same state
writeObject(oldValue);
} catch (Exception e) {
@@ -399,8 +398,7 @@ public class Encoder {
if (o == null) {
return;
}
- Class type = o.getClass();
- getPersistenceDelegate(type).writeObject(o, this);
+ getPersistenceDelegate(o.getClass()).writeObject(o, this);
}
/**
@@ -421,13 +419,8 @@ public class Encoder {
if (oldStat == null) {
throw new NullPointerException();
}
+ Statement newStat = createNewStatement(oldStat);
try {
- // copy to newStat
- Object newTarget = forceNew(oldStat.getTarget());
- Object newArgs[] = forceNewArray(oldStat.getArguments());
- Statement newStat = new Statement(newTarget, oldStat
- .getMethodName(), newArgs);
-
// execute newStat
newStat.execute();
} catch (Exception e) {
@@ -435,5 +428,4 @@ public class Encoder {
"failed to write statement: " + oldStat, e)); //$NON-NLS-1$
}
}
-
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/PersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/PersistenceDelegate.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/PersistenceDelegate.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/PersistenceDelegate.java Thu Oct 7 14:56:06 2010
@@ -90,10 +90,7 @@ public abstract class PersistenceDelegat
* false
*/
protected boolean mutatesTo(Object o1, Object o2) {
- if (null == o1 || null == o2 ) {
- return false;
- }
- return o1.getClass() == o2.getClass();
+ return null != o1 && null != o2 && o1.getClass() == o2.getClass();
}
/**
@@ -112,20 +109,16 @@ public abstract class PersistenceDelegat
*/
public void writeObject(Object oldInstance, Encoder out) {
Object newInstance = out.get(oldInstance);
+ Class<?> clazz = oldInstance.getClass();
if (mutatesTo(oldInstance, newInstance)) {
- initialize(oldInstance.getClass(), oldInstance, newInstance, out);
+ initialize(clazz, oldInstance, newInstance, out);
} else {
out.remove(oldInstance);
- Expression exp = instantiate(oldInstance, out);
- out.writeExpression(exp);
+ out.writeExpression(instantiate(oldInstance, out));
newInstance = out.get(oldInstance);
-
if (newInstance != null) {
- initialize(oldInstance.getClass(), oldInstance,
- newInstance, out);
+ initialize(clazz, oldInstance, newInstance, out);
}
}
}
-
-}
-
+}
\ No newline at end of file
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java Thu Oct 7 14:56:06 2010
@@ -27,6 +27,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
@@ -44,6 +45,8 @@ import org.apache.harmony.beans.internal
*/
public class XMLEncoder extends Encoder {
+ private static final String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$
+
private static int DEADLOCK_THRESHOLD = 7;
/*
@@ -92,11 +95,11 @@ public class XMLEncoder extends Encoder
private Object owner = null;
- private ReferenceMap records = new ReferenceMap();
+ private IdentityHashMap<Object, Record> objRecordMap = new IdentityHashMap<Object, Record>();
- private ReferenceMap objPrePendingCache = new ReferenceMap();
+ private IdentityHashMap<Class<?>, Integer> clazzCounterMap = new IdentityHashMap<Class<?>, Integer>();
- private ReferenceMap clazzCounterMap = new ReferenceMap();
+ private IdentityHashMap<Object, ArrayList<Object>> objPrePendingCache = new IdentityHashMap<Object, ArrayList<Object>>();
private boolean writingObject = false;
@@ -109,11 +112,10 @@ public class XMLEncoder extends Encoder
public XMLEncoder(OutputStream out) {
if (null != out) {
try {
- this.out = new PrintWriter(
- new OutputStreamWriter(out, "UTF-8"), true); //$NON-NLS-1$
+ this.out = new PrintWriter(new OutputStreamWriter(out,
+ DEFAULT_ENCODING), true);
} catch (UnsupportedEncodingException e) {
- // never occur
- e.printStackTrace();
+ // should never occur
}
}
}
@@ -166,7 +168,7 @@ public class XMLEncoder extends Encoder
for (Iterator<Object> iter = flushPending.iterator(); iter
.hasNext();) {
Object o = iter.next();
- Record rec = (Record) records.get(o);
+ Record rec = objRecordMap.get(o);
if (rec != null) {
preprocess(o, rec);
}
@@ -182,7 +184,7 @@ public class XMLEncoder extends Encoder
}
// clear statement records
- records.clear();
+ objRecordMap.clear();
flushPendingStat.clear();
objPrePendingCache.clear();
clazzCounterMap.clear();
@@ -201,54 +203,33 @@ public class XMLEncoder extends Encoder
if (obj == null) {
out.println("<null />");
} else if (obj instanceof String) {
- Record rec = (Record) records.get(obj);
+ Record rec = objRecordMap.get(obj);
if (null != rec) {
- if (flushPendingStat.contains(obj)) {
- flushExpression(obj, rec, indent - 3, true);
- } else {
- flushExpression(obj, rec, indent - 3, false);
- }
+ flushExpression(obj, rec, indent - 3,
+ flushPendingStat.contains(obj));
return;
}
out.print("<string>");
flushString((String) obj);
out.println("</string>");
} else if (obj instanceof Class<?>) {
- out.print("<class>");
- out.print(((Class<?>) obj).getName());
- out.println("</class>");
+ out.println("<class>" + ((Class<?>) obj).getName() + "</class>");
} else if (obj instanceof Boolean) {
- out.print("<boolean>");
- out.print(obj);
- out.println("</boolean>");
+ out.println("<boolean>" + obj + "</boolean>");
} else if (obj instanceof Byte) {
- out.print("<byte>");
- out.print(obj);
- out.println("</byte>");
+ out.println("<byte>" + obj + "</byte>");
} else if (obj instanceof Character) {
- out.print("<char>");
- out.print(obj);
- out.println("</char>");
+ out.println("<char>" + obj + "</char>");
} else if (obj instanceof Double) {
- out.print("<double>");
- out.print(obj);
- out.println("</double>");
+ out.println("<double>" + obj + "</double>");
} else if (obj instanceof Float) {
- out.print("<float>");
- out.print(obj);
- out.println("</float>");
+ out.println("<float>" + obj + "</float>");
} else if (obj instanceof Integer) {
- out.print("<int>");
- out.print(obj);
- out.println("</int>");
+ out.println("<int>" + obj + "</int>");
} else if (obj instanceof Long) {
- out.print("<long>");
- out.print(obj);
- out.println("</long>");
+ out.println("<long>" + obj + "</long>");
} else if (obj instanceof Short) {
- out.print("<short>");
- out.print(obj);
- out.println("</short>");
+ out.println("<short>" + obj + "</short>");
} else {
getExceptionListener().exceptionThrown(
new Exception(Messages.getString("beans.73", obj)));
@@ -287,14 +268,15 @@ public class XMLEncoder extends Encoder
private void flushIndent(int indent) {
for (int i = 0; i < indent; i++) {
- out.print(" "); //$NON-NLS-1$
+ out.print(' ');
}
}
private void flushObject(Object obj, int indent) {
- Record rec = (Record) records.get(obj);
- if (rec == null && !isBasicType(obj))
+ Record rec = objRecordMap.get(obj);
+ if (rec == null && !isBasicType(obj)) {
return;
+ }
if (obj == owner && this.needOwner) {
flushOwner(obj, rec, indent);
@@ -305,11 +287,7 @@ public class XMLEncoder extends Encoder
if (isBasicType(obj)) {
flushBasicObject(obj, indent);
} else {
- if (flushPendingStat.contains(obj)) {
- flushExpression(obj, rec, indent, true);
- } else {
- flushExpression(obj, rec, indent, false);
- }
+ flushExpression(obj, rec, indent, flushPendingStat.contains(obj));
}
}
@@ -451,7 +429,7 @@ public class XMLEncoder extends Encoder
Object args[] = stat.getArguments();
// special case for array
- if (Array.class == target && "newInstance".equals(method)) {
+ if (Array.class == target && BeansUtils.NEWINSTANCE.equals(method)) {
flushStatArray(stat, id, subStats, indent);
return;
}
@@ -643,10 +621,10 @@ public class XMLEncoder extends Encoder
for (int i = 0; i < subStats.size(); i++) {
Statement subStat = (Statement) subStats.get(i);
try {
- if (subStat instanceof Expression) {
+ if (subStat.getClass() == Expression.class) {
Expression subExp = (Expression) subStat;
Object obj = subExp.getValue();
- Record rec = (Record) records.get(obj);
+ Record rec = objRecordMap.get(obj);
flushExpression(obj, rec, indent + INDENT_UNIT, true);
} else {
flushStatement(subStat, null, Collections.EMPTY_LIST,
@@ -678,21 +656,21 @@ public class XMLEncoder extends Encoder
}
private boolean isGetArrayStat(Object target, String method, Object[] args) {
- return ("get".equals(method) && args.length == 1 //$NON-NLS-1$
+ return (BeansUtils.GET.equals(method) && args.length == 1
&& args[0] instanceof Integer && target.getClass().isArray());
}
private boolean isGetPropertyStat(String method, Object[] args) {
- return (method.startsWith("get") && method.length() > 3 && args.length == 0); //$NON-NLS-1$
+ return (method.startsWith(BeansUtils.GET) && method.length() > 3 && args.length == 0);
}
private boolean isSetArrayStat(Object target, String method, Object[] args) {
- return ("set".equals(method) && args.length == 2 //$NON-NLS-1$
+ return (BeansUtils.SET.equals(method) && args.length == 2
&& args[0] instanceof Integer && target.getClass().isArray());
}
private boolean isSetPropertyStat(String method, Object[] args) {
- return (method.startsWith("set") && method.length() > 3 && args.length == 1); //$NON-NLS-1$
+ return (method.startsWith(BeansUtils.SET) && method.length() > 3 && args.length == 1);
}
/*
@@ -719,15 +697,15 @@ public class XMLEncoder extends Encoder
// do it recursively
if (null != rec.exp) {
// deal with 'field' property
- Record targetRec = (Record) records.get(rec.exp.getTarget());
+ Record targetRec = objRecordMap.get(rec.exp.getTarget());
if (targetRec != null && targetRec.exp != null
&& "getField".equals(targetRec.exp.getMethodName())) {
- records.remove(obj);
+ objRecordMap.remove(obj);
}
Object args[] = rec.exp.getArguments();
for (int i = 0; i < args.length; i++) {
- Record argRec = (Record) records.get(args[i]);
+ Record argRec = objRecordMap.get(args[i]);
if (argRec != null) {
preprocess(args[i], argRec);
}
@@ -736,10 +714,10 @@ public class XMLEncoder extends Encoder
for (Iterator<?> iter = rec.stats.iterator(); iter.hasNext();) {
Statement subStat = (Statement) iter.next();
- if (subStat instanceof Expression) {
+ if (subStat.getClass() == Expression.class) {
try {
Expression subExp = (Expression) subStat;
- Record subRec = (Record) records.get(subExp.getValue());
+ Record subRec = objRecordMap.get(subExp.getValue());
if (subRec == null || subRec.exp == null
|| subRec.exp != subExp) {
iter.remove();
@@ -764,7 +742,7 @@ public class XMLEncoder extends Encoder
Object subStatArgs[] = subStat.getArguments();
for (int i = 0; i < subStatArgs.length; i++) {
- Record argRec = (Record) records.get(subStatArgs[i]);
+ Record argRec = objRecordMap.get(subStatArgs[i]);
if (argRec != null) {
preprocess(subStatArgs[i], argRec);
}
@@ -774,24 +752,18 @@ public class XMLEncoder extends Encoder
private void recordExpression(Object value, Expression exp) {
// record how a new object is created or obtained
- Record rec = (Record) records.get(value);
+ Record rec = objRecordMap.get(value);
if (rec == null) {
rec = new Record();
- records.put(value, rec);
+ objRecordMap.put(value, rec);
}
if (rec.exp == null) {
- // it is generated by its sub stats
- for (Iterator<?> iter = rec.stats.iterator(); iter.hasNext();) {
- Statement stat = (Statement) iter.next();
- try {
- if (stat instanceof Expression) {
- flushPrePending.add(value);
- }
- } catch (Exception e) {
- e.printStackTrace();
+ // it is generated by its sub statements
+ for (Statement statement : rec.stats) {
+ if (statement.getClass() == Expression.class) {
+ flushPrePending.add(value);
}
-
}
}
@@ -807,18 +779,19 @@ public class XMLEncoder extends Encoder
}
private void recordStatement(Statement stat) {
- if (null == stat)
+ if (null == stat) {
return;
+ }
// deal with 'owner' property
if (stat.getTarget() == owner && owner != null) {
needOwner = true;
}
// record how a statement affects the target object
- Record rec = (Record) records.get(stat.getTarget());
+ Record rec = objRecordMap.get(stat.getTarget());
if (rec == null) {
rec = new Record();
- records.put(stat.getTarget(), rec);
+ objRecordMap.put(stat.getTarget(), rec);
}
rec.stats.add(stat);
}
@@ -837,7 +810,7 @@ public class XMLEncoder extends Encoder
Object obj = value;
while (obj != null) {
- Record rec = (Record) records.get(obj);
+ Record rec = objRecordMap.get(obj);
if (rec != null && rec.exp != null) {
obj = rec.exp.getTarget();
@@ -881,26 +854,16 @@ public class XMLEncoder extends Encoder
boolean oldWritingObject = writingObject;
writingObject = true;
// get expression value
- Object oldValue = null;
-
- try {
- oldValue = oldExp.getValue();
- } catch (Exception e) {
- getExceptionListener().exceptionThrown(
- new Exception("failed to execute expression: " //$NON-NLS-1$
- + oldExp, e));
- return;
- }
-
+ Object oldValue = expressionValue(oldExp);
// check existence
- if (get(oldValue) != null
- && (!(oldValue instanceof String) || oldWritingObject)) {
+ if (oldValue == null || get(oldValue) != null
+ && (oldWritingObject || oldValue.getClass() != String.class)) {
return;
}
// record how the object is obtained
if (!isBasicType(oldValue)
- || (oldValue instanceof String && !oldWritingObject)) {
+ || (!oldWritingObject && oldValue.getClass() == String.class)) {
recordExpression(oldValue, oldExp);
}
@@ -908,7 +871,6 @@ public class XMLEncoder extends Encoder
if (checkDeadLoop(oldValue)) {
return;
}
-
super.writeExpression(oldExp);
writingObject = oldWritingObject;
}
@@ -917,12 +879,10 @@ public class XMLEncoder extends Encoder
* Records the object so that it can be written out later, then calls super
* implementation.
*/
- @SuppressWarnings("unchecked")
@Override
public void writeObject(Object o) {
synchronized (this) {
- ArrayList<Object> prePending = (ArrayList<Object>) objPrePendingCache
- .get(o);
+ ArrayList<Object> prePending = objPrePendingCache.get(o);
if (prePending == null) {
boolean oldWritingObject = writingObject;
writingObject = true;
@@ -976,9 +936,9 @@ public class XMLEncoder extends Encoder
System.err.println("Continuing...");
return;
}
+
// record how the object is changed
recordStatement(oldStat);
-
super.writeStatement(oldStat);
}
}
\ No newline at end of file
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java Thu Oct 7 14:56:06 2010
@@ -43,6 +43,12 @@ public class StartTlsResponseImpl extend
private boolean isHandshaked = false; // is handshake finished
+ private static class HandshakeMonitor {
+ // for identify local locks.
+ };
+
+ private HandshakeMonitor handshakeMonitor = new HandshakeMonitor();
+
private SSLSocket negotiatedSslSocket = null; // negotiated ssl socket
@Override
@@ -85,14 +91,23 @@ public class StartTlsResponseImpl extend
sslSocket
.addHandshakeCompletedListener(new HandshakeCompletedListener() {
public void handshakeCompleted(HandshakeCompletedEvent event) {
- isHandshaked = true;
+ synchronized(handshakeMonitor) {
+ isHandshaked = true;
+ handshakeMonitor.notify();
+ }
}
});
sslSocket.startHandshake();
- while (!isHandshaked) {
- // Wait for handshake finish.
+ synchronized(handshakeMonitor) {
+ while (!isHandshaked) {
+ try {
+ handshakeMonitor.wait();
+ } catch (InterruptedException e) {
+ // continue the loop
+ }
+ }
}
HostnameVerifier defaultVerifier = new HostnameVerifier() {
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/StringBuilder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/StringBuilder.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/StringBuilder.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/StringBuilder.java Thu Oct 7 14:56:06 2010
@@ -345,7 +345,7 @@ public final class StringBuilder extends
}
/**
- * Deletes the character at the specified index. shifts any remaining
+ * Deletes the character at the specified index. Shifts any remaining
* characters to the left.
*
* @param index
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c Thu Oct 7 14:56:06 2010
@@ -346,14 +346,14 @@ Java_org_apache_harmony_luni_platform_OS
/* output result to int array */
flagArray = (*env)->GetIntArrayElements(env, outFlags, &isCopy);
for (val=0; val<countReadC; val++) {
- if (my_pollfds[val].revents & (POLLIN | POLLPRI)) {
+ if (my_pollfds[val].revents & (POLLIN | POLLPRI | POLLHUP | POLLERR)) {
flagArray[val] = SOCKET_OP_READ;
changed=1;
}
}
for (val=0; val<countWriteC; val++) {
- if (my_pollfds[val+countReadC].revents & POLLOUT) {
+ if (my_pollfds[val+countReadC].revents & (POLLOUT | POLLHUP | POLLERR)) {
flagArray[val+countReadC] = SOCKET_OP_WRITE;
changed=1;
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c Thu Oct 7 14:56:06 2010
@@ -400,11 +400,13 @@ PORT_ACCESS_FROM_ENV (env);
I_32
getPlatformIsWriteOnly (JNIEnv * env, char *path)
{
+ PORT_ACCESS_FROM_ENV(env);
HANDLE fHandle;
wchar_t *pathW;
convert_path_to_unicode(env,path,&pathW);
fHandle = CreateFileW(pathW, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ jclmem_free_memory(env, pathW);
if (fHandle == INVALID_HANDLE_VALUE) {
return 1;
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java Thu Oct 7 14:56:06 2010
@@ -39,12 +39,15 @@ final class SelectionKeyImpl extends Abs
private int index;
+ private boolean stateChange = false;
+
public SelectionKeyImpl(AbstractSelectableChannel channel, int operations,
Object attachment, SelectorImpl selector) {
this.channel = channel;
interestOps = operations;
this.selector = selector;
attach(attachment);
+ this.stateChange = true;
}
@Override
@@ -73,6 +76,9 @@ final class SelectionKeyImpl extends Abs
throw new IllegalArgumentException();
}
synchronized (selector.keysLock) {
+ if (interestOps != operations) {
+ stateChange = true;
+ }
interestOps = operations;
selector.modKey(this);
}
@@ -105,6 +111,14 @@ final class SelectionKeyImpl extends Abs
this.index = index;
}
+ boolean getStateChange() {
+ return stateChange;
+ }
+
+ void setStateChange(boolean flag) {
+ this.stateChange = flag;
+ }
+
private void checkValid() {
if (!isValid()) {
throw new CancelledKeyException();
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java Thu Oct 7 14:56:06 2010
@@ -563,20 +563,20 @@ final class SelectorImpl extends Abstrac
if (key.isConnected()) {
selectedOp = OP_WRITE & ops;
} else {
- selectedOp = OP_CONNECT & ops;
+ selectedOp = (OP_CONNECT | OP_WRITE) & ops;
}
break;
}
+ key.setReadyOps(selectedOp);
if (0 != selectedOp) {
boolean wasSelected = mutableSelectedKeys.contains(key);
- if (wasSelected && key.readyOps() != selectedOp) {
- key.setReadyOps(key.readyOps() | selectedOp);
- selected++;
- } else if (!wasSelected) {
- key.setReadyOps(selectedOp);
+ if (!wasSelected) {
mutableSelectedKeys.add(key);
+ }
+ if (key.getStateChange()) {
selected++;
+ key.setStateChange(false);
}
}
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java Thu Oct 7 14:56:06 2010
@@ -19,21 +19,18 @@ package org.apache.harmony.nio.tests.jav
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ClosedSelectorException;
+import java.nio.channels.Pipe;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
-import java.nio.channels.Pipe;
import java.nio.channels.spi.SelectorProvider;
import java.util.Set;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
import junit.framework.TestCase;
import tests.support.Support_PortManager;
@@ -406,6 +403,52 @@ public class SelectorTest extends TestCa
assertNull(failure.get());
}
+ public void testOpChange() throws Exception {
+ SocketChannel sc = SocketChannel.open();
+ sc.configureBlocking(false);
+ sc.register(selector, SelectionKey.OP_CONNECT);
+ try {
+ sc.connect(LOCAL_ADDRESS);
+ int count = blockingSelect(SelectType.TIMEOUT, 100);
+ assertEquals(1, count);
+ Set<SelectionKey> selectedKeys = selector.selectedKeys();
+ assertEquals(1, selectedKeys.size());
+ SelectionKey key = selectedKeys.iterator().next();
+ assertEquals(sc.keyFor(selector), key);
+ assertEquals(SelectionKey.OP_CONNECT, key.readyOps());
+ // select again, it should return 0
+ count = selectOnce(SelectType.TIMEOUT, 100);
+ assertEquals(0, count);
+ // but selectedKeys remains the same as previous
+ assertSame(selectedKeys, selector.selectedKeys());
+ sc.finishConnect();
+
+ // same selector, but op is changed
+ SelectionKey key1 = sc.register(selector, SelectionKey.OP_WRITE);
+ assertEquals(key, key1);
+ count = blockingSelect(SelectType.TIMEOUT, 100);
+ assertEquals(1, count);
+ selectedKeys = selector.selectedKeys();
+ assertEquals(1, selectedKeys.size());
+ key = selectedKeys.iterator().next();
+ assertEquals(key, key1);
+ assertEquals(SelectionKey.OP_WRITE, key.readyOps());
+
+ selectedKeys.clear();
+ } finally {
+ try {
+ ssc.accept().close();
+ } catch (Exception e) {
+ // do nothing
+ }
+ try {
+ sc.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ }
+
private void assert_select_SelectorClosed(SelectType type, int timeout)
throws IOException {
// selector is closed
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java Thu Oct 7 14:56:06 2010
@@ -438,14 +438,13 @@ public class BcBands extends BandSet {
bcLabelRelativeOffsets.add(byteCodeOffset);
}
int padding = (byteCodeOffset + 1) % 4 == 0 ? 0 : 4 - ((byteCodeOffset + 1) % 4);
- byteCodeOffset += padding + 8 + 8 * keys.length;
+ byteCodeOffset += 1 + padding + 8 + 8 * keys.length;
updateRenumbering();
}
public void visitMethodInsn(int opcode, String owner, String name,
String desc) {
byteCodeOffset += 3;
- updateRenumbering();
switch (opcode) {
case 182: // invokevirtual
case 183: // invokespecial
@@ -495,11 +494,13 @@ public class BcBands extends BandSet {
bcCodes.add(opcode);
break;
case 185: // invokeinterface
+ byteCodeOffset += 2;
CPMethodOrField cpIMethod = cpBands.getCPIMethod(owner, name, desc);
bcIMethodRef.add(cpIMethod);
bcCodes.add(INVOKEINTERFACE);
break;
}
+ updateRenumbering();
}
public void visitMultiANewArrayInsn(String desc, int dimensions) {
@@ -522,7 +523,7 @@ public class BcBands extends BandSet {
bcLabel.add(labels[i]);
bcLabelRelativeOffsets.add(byteCodeOffset);
}
- int padding = (byteCodeOffset + 1) % 4 == 0 ? 0 : 4 - ((byteCodeOffset + 1) % 4);
+ int padding = byteCodeOffset % 4 == 0 ? 0 : 4 - (byteCodeOffset % 4);
byteCodeOffset+= (padding + 12 + 4 * labels.length);
updateRenumbering();
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/LogStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/LogStreamTest.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/LogStreamTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/LogStreamTest.java Thu Oct 7 14:56:06 2010
@@ -18,8 +18,10 @@
package org.apache.harmony.rmi.server;
import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
import java.io.PrintStream;
import java.rmi.server.LogStream;
+
import junit.framework.TestCase;
public class LogStreamTest extends TestCase {
@@ -27,13 +29,13 @@ public class LogStreamTest extends TestC
* Test for java.rmi.server.LogStream.write(int b)
*/
public void testWriteI() throws Exception {
- //regression test for HARMONY-1271
- LogStream.log("tst").write((int)'\n');
+ // regression test for HARMONY-1271
+ LogStream.log("tst").write((int) '\n');
- //regression test for HARMONY-994
+ // regression test for HARMONY-994
LogStream.log("tst").write(0);
}
-
+
public void testSetOutputStreamBad() throws Exception {
// Regression test HARMONY-1198
try {
@@ -46,41 +48,54 @@ public class LogStreamTest extends TestC
}
/**
- * Test for java.rmi.server.LogStream.write(byte[], int, int)
- * testing invalid offsets/lengths.
+ * Test for java.rmi.server.LogStream.write(byte[], int, int) testing
+ * invalid offsets/lengths.
*/
public void testWriteArrInvalidOffLen() throws Exception {
// Regression test for HARMONY-1691
// list of invalid offsets/lengths pairs
- int[][] invalidPairs = new int[][] {
- { -2, 1 },
- { 0, -6 },
- { 6, 1 },
- { 0, 6 } };
+ int[][] invalidPairs = new int[][] { { -2, 1 }, { 0, -6 }, { 6, 1 },
+ { 0, 6 } };
// store original default stream for LogStream
PrintStream prevOut = LogStream.getDefaultStream();
try {
// set empty default stream to not print garbage to System.out/err
- LogStream.setDefaultStream(
- new PrintStream(new ByteArrayOutputStream()));
+ LogStream.setDefaultStream(new PrintStream(
+ new ByteArrayOutputStream()));
LogStream ls = LogStream.log("test");
for (int i = 0; i < invalidPairs.length; ++i) {
try {
- ls.write(new byte[] { 1, 1 },
- invalidPairs[i][0], invalidPairs[i][1]);
+ ls.write(new byte[] { 1, 1 }, invalidPairs[i][0],
+ invalidPairs[i][1]);
fail("IndexOutOfBoundsException "
+ "is not thrown when off = " + invalidPairs[i][0]
+ ", len = " + invalidPairs[i][1]);
} catch (IndexOutOfBoundsException e) {
- //expected
+ // expected
}
}
} finally {
// restore original stream
LogStream.setDefaultStream(prevOut);
}
+
+ }
+
+ public void testParseLevel() {
+ assertEquals(LogStream.parseLevel("BRIEF"), LogStream.BRIEF);
+ assertEquals(LogStream.parseLevel("SILENT"), LogStream.SILENT);
+ assertEquals(LogStream.parseLevel("VERBOSE"), LogStream.VERBOSE);
}
+
+ public void testGetOutputStream() {
+ LogStream log = LogStream.log("abc");
+ OutputStream output = log.getOutputStream();
+ PrintStream defaultPrintStream = LogStream.getDefaultStream();
+
+ assertEquals(output.toString(), defaultPrintStream.toString());
+ }
+
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java Thu Oct 7 14:56:06 2010
@@ -19,10 +19,13 @@
package org.apache.harmony.rmi.server;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.rmi.server.RMIClassLoader;
+import java.rmi.server.RMIClassLoaderSpi;
import java.security.Permission;
+
import junit.framework.TestCase;
public class RMIClassLoaderTest extends TestCase {
@@ -52,8 +55,8 @@ public class RMIClassLoaderTest extends
* to be sure this path will be the first after sorting
*/
"/_fake.jar" };
- Class<?> c = RMIClassLoader.loadClass("file://" + paths[0] + " file://" + paths[1],
- "TestClass", null);
+ Class<?> c = RMIClassLoader.loadClass("file://" + paths[0]
+ + " file://" + paths[1], "TestClass", null);
ClassLoader cl = c.getClassLoader();
if (cl instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) cl).getURLs();
@@ -63,8 +66,8 @@ public class RMIClassLoaderTest extends
String failStr = "";
for (int i = 0; i < urls.length; ++i) {
if (!urls[i].getPath().equals(paths[i])) {
- failStr += "\nURL[" + i + "].getPath() = " + urls[i].getPath()
- + ", expected: " + paths[i];
+ failStr += "\nURL[" + i + "].getPath() = "
+ + urls[i].getPath() + ", expected: " + paths[i];
}
}
if (!failStr.equals("")) {
@@ -80,59 +83,266 @@ public class RMIClassLoaderTest extends
}
/**
- * Test for java.rmi.server.RMIClassLoader.loadProxyClass(String, String[], ClassLoader)
- * testing invalid url as a codebase.
- */
+ * Test for java.rmi.server.RMIClassLoader.loadProxyClass(String, String[],
+ * ClassLoader) testing invalid url as a codebase.
+ */
public void testLoadProxyClassInvalidCodebase() throws Exception {
- //Regression for HARMONY-1133
+ // Regression for HARMONY-1133
SecurityManager previous = System.getSecurityManager();
System.setSecurityManager(null);
-
+
try {
RMIClassLoader.loadProxyClass("zzz", new String[] {}, null);
fail("MalformedURLException expected");
- } catch (MalformedURLException e) {
- //expected
+ } catch (MalformedURLException e) {
+ // expected
} finally {
- System.setSecurityManager(previous);
+ System.setSecurityManager(previous);
}
}
/**
- * Test for java.rmi.server.RMIClassLoader.loadClass(String, String)
- * testing invalid url as a codebase.
+ * Test for java.rmi.server.RMIClassLoader.loadClass(String, String) testing
+ * invalid url as a codebase.
*/
public void testLoadClassInvalidCodebase() throws Exception {
- //Regression for HARMONY-1133
+ // Regression for HARMONY-1133
SecurityManager previous = System.getSecurityManager();
System.setSecurityManager(null);
-
- try {
+
+ try {
RMIClassLoader.loadClass("zzz", "a123");
fail("MalformedURLException expected");
- } catch (MalformedURLException e) {
- //expected
+ } catch (MalformedURLException e) {
+ // expected
} finally {
- System.setSecurityManager(previous);
- }
+ System.setSecurityManager(previous);
+ }
}
/**
- * Test for java.rmi.server.RMIClassLoader.getClassLoader(String)
- * testing invalid url as a codebase.
+ * Test for java.rmi.server.RMIClassLoader.getClassLoader(String) testing
+ * invalid url as a codebase.
*/
public void testGetClassLoaderInvalidCodebase() throws Exception {
- //Regression for HARMONY-1134
+ // Regression for HARMONY-1134
SecurityManager previous = System.getSecurityManager();
System.setSecurityManager(null);
- try {
+ try {
RMIClassLoader.getClassLoader("zzz");
fail("MalformedURLException expected");
- } catch (MalformedURLException e) {
- //expected
+ } catch (MalformedURLException e) {
+ // expected
+ } finally {
+ System.setSecurityManager(previous);
+ }
+ }
+
+ /**
+ * Modify the above method to test loadClass, loadClass(String, String) for
+ * coverage.
+ */
+ public void testLoadClassCodebaseOrder2() throws Exception {
+ SecurityManager previous = System.getSecurityManager();
+ System.setSecurityManager(new SecurityManager() {
+ @Override
+ public void checkPermission(Permission perm) {
+ /*
+ * Override checkPermission to allow everything. Specifically,
+ * we want to allow the SecurityManager to be set to null at the
+ * end of the test and we want to allow the 'testClass.jar' file
+ * to be allowed to load.
+ */
+ return;
+ }
+ });
+ try {
+ URL testJarURL = getClass().getResource("testClass.jar");
+ String[] paths = new String[] { testJarURL.getPath(),
+ /*
+ * to be sure this path will be the first after sorting
+ */
+ "/_fake.jar" };
+ Class<?> c = RMIClassLoader.loadClass("file://" + paths[0]
+ + " file://" + paths[1], "TestClass");
+ ClassLoader cl = c.getClassLoader();
+ if (cl instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader) cl).getURLs();
+ if (urls.length != 2) {
+ fail("Unexpected number of URLs: " + urls.length);
+ }
+ String failStr = "";
+ for (int i = 0; i < urls.length; ++i) {
+ if (!urls[i].getPath().equals(paths[i])) {
+ failStr += "\nURL[" + i + "].getPath() = "
+ + urls[i].getPath() + ", expected: " + paths[i];
+ }
+ }
+ if (!failStr.equals("")) {
+ fail(failStr);
+ }
+ } else {
+ fail("Class is loaded by non-URLClassLoader");
+ }
+ } finally {
+ // reset the security manager back to null state
+ System.setSecurityManager(previous);
+ }
+ }
+
+ /**
+ * Modify the above method to test loadClass, loadClass(String, String) for
+ * coverage.
+ */
+ public void testLoadClassCodebaseOrder3() throws Exception {
+ SecurityManager previous = System.getSecurityManager();
+ System.setSecurityManager(new SecurityManager() {
+ @Override
+ public void checkPermission(Permission perm) {
+ /*
+ * Override checkPermission to allow everything. Specifically,
+ * we want to allow the SecurityManager to be set to null at the
+ * end of the test and we want to allow the 'testClass.jar' file
+ * to be allowed to load.
+ */
+ return;
+ }
+ });
+ try {
+ URL testJarURL = getClass().getResource("testClass.jar");
+ String[] paths = new String[] { testJarURL.getPath(),
+ /*
+ * to be sure this path will be the first after sorting
+ */
+ "/_fake.jar" };
+
+ Class<?> c = RMIClassLoader.loadClass(new URI("file://" + paths[0])
+ .toURL(), "TestClass");
+
+ assertNotNull(c);
+
+ } catch (Exception e) {
+ fail("class should be loaded");
} finally {
- System.setSecurityManager(previous);
- }
+ // reset the security manager back to null state
+ System.setSecurityManager(previous);
+ }
+ }
+
+ /**
+ * Modify the above method to test testGetSecurityContext for coverage.
+ */
+ public void testGetSecurityContext() throws Exception {
+ SecurityManager previous = System.getSecurityManager();
+ SecurityManager sm = new SecurityManager() {
+ @Override
+ public void checkPermission(Permission perm) {
+ /*
+ * Override checkPermission to allow everything. Specifically,
+ * we want to allow the SecurityManager to be set to null at the
+ * end of the test and we want to allow the 'testClass.jar' file
+ * to be allowed to load.
+ */
+ return;
+ }
+
+ };
+ System.setSecurityManager(sm);
+ try {
+ URL testJarURL = getClass().getResource("testClass.jar");
+ String[] paths = new String[] { testJarURL.getPath(),
+ /*
+ * to be sure this path will be the first after sorting
+ */
+ "/_fake.jar" };
+
+ Class<?> c = RMIClassLoader.loadClass(new URI("file://" + paths[0])
+ .toURL(), "TestClass");
+
+ assertNotNull(c);
+
+ Object sc = RMIClassLoader.getSecurityContext(c.getClassLoader());
+ if (true) {
+ return;
+ }
+
+ // This is the ri behavior, spec for what to return is not found
+ assertEquals(((URL) sc).toString(), testJarURL.toString());
+ } finally {
+ // reset the security manager back to null state
+ System.setSecurityManager(previous);
+ }
+ }
+
+ public void testGetDefaultProvideInstance() {
+ assertTrue(RMIClassLoader.getDefaultProviderInstance() instanceof RMIClassLoaderSpi);
+ }
+
+ /**
+ * Modify the above method to test loadClass, loadClass(String, String) for
+ * coverage.
+ */
+ public void testLoadClassCodebaseOrder4() throws Exception {
+ SecurityManager previous = System.getSecurityManager();
+ System.setSecurityManager(new SecurityManager() {
+ @Override
+ public void checkPermission(Permission perm) {
+ /*
+ * Override checkPermission to allow everything. Specifically,
+ * we want to allow the SecurityManager to be set to null at the
+ * end of the test and we want to allow the 'testClass.jar' file
+ * to be allowed to load.
+ */
+ return;
+ }
+ });
+ try {
+ URL testJarURL = getClass().getResource("testClass.jar");
+ String[] paths = new String[] { testJarURL.getPath(),
+ /*
+ * to be sure this path will be the first after sorting
+ */
+ "/_fake.jar" };
+
+ ClassLoader cl = RMIClassLoader.getClassLoader(new URI("file://"
+ + paths[0]).toURL().toString());
+ Class<?> c = cl.loadClass("TestClass");
+
+ assertNotNull(c);
+
+ } finally {
+ // reset the security manager back to null state
+ System.setSecurityManager(previous);
+ }
+ }
+
+ /**
+ * Modify the above method to test loadClass, loadClass(String, String) for
+ * coverage.
+ */
+ public void testLoadClassCodebaseOrder5() throws Exception {
+ SecurityManager previous = System.getSecurityManager();
+ System.setSecurityManager(new SecurityManager() {
+ @Override
+ public void checkPermission(Permission perm) {
+ /*
+ * Override checkPermission to allow everything. Specifically,
+ * we want to allow the SecurityManager to be set to null at the
+ * end of the test and we want to allow the 'testClass.jar' file
+ * to be allowed to load.
+ */
+ return;
+ }
+ });
+ try {
+ Class<?> c = RMIClassLoader.loadClass("TestClass");
+ fail();
+ } catch (ClassNotFoundException e) {
+ // expected
+ } finally {
+ // reset the security manager back to null state
+ System.setSecurityManager(previous);
+ }
}
}
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/ServerNotActiveExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/ServerNotActiveExceptionTest.java?rev=1005476&r1=1005475&r2=1005476&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/ServerNotActiveExceptionTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/ServerNotActiveExceptionTest.java Thu Oct 7 14:56:06 2010
@@ -66,6 +66,12 @@ public class ServerNotActiveExceptionTes
ServerNotActiveException e = new ServerNotActiveException(errorMessage);
assertEquals(errorMessage, e.getMessage());
}
+
+
+ public void test_Constructor(){
+ ServerNotActiveException e = new ServerNotActiveException();
+ assertNull(e.getMessage());
+ }
// comparator for ServerNotActiveException objects
private static final SerializableAssert comparator = new SerializableAssert() {