You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2009/01/20 06:47:41 UTC
svn commit: r735939 [1/5] - in /harmony/enhanced/classlib/branches/java6: ./
modules/auth/META-INF/ modules/beans/src/main/java/java/beans/
modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/
modules/beans/src/test/support/java/org/a...
Author: tonywu
Date: Mon Jan 19 21:47:38 2009
New Revision: 735939
URL: http://svn.apache.org/viewvc?rev=735939&view=rev
Log:
Merge updates from classlib trunk@735919 since r727674
Added:
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/aix/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/aix/
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/aix/OSResourcesMonitor.c
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/aix/OSResourcesMonitor.c
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/apache/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/apache/harmony/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/apache/harmony/luni/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/
- copied from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java
harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/resources/Package/hyts_d.jar
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Package/hyts_d.jar
harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/resources/Package/hyts_d1.jar
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Package/hyts_d1.jar
harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/resources/Package/hyts_d2.jar
- copied unchanged from r735919, harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Package/hyts_d2.jar
Modified:
harmony/enhanced/classlib/branches/java6/ (props changed)
harmony/enhanced/classlib/branches/java6/build.xml
harmony/enhanced/classlib/branches/java6/modules/auth/META-INF/MANIFEST.MF
harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Introspector.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.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/jndi/META-INF/MANIFEST.MF
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java
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/net/URLClassLoader.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/luniglob.c
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/PackageTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java
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/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/VectorTest.java
harmony/enhanced/classlib/branches/java6/modules/nio/META-INF/MANIFEST.MF
harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java
harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
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/MetadataBandGroup.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
harmony/enhanced/classlib/branches/java6/modules/prefs/.settings/org.eclipse.jdt.core.prefs
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/InvalidPreferencesFormatException.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/Preferences.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/PreferencesFactory.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesFactoryImpl.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/XMLParser.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/AllTests.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java
harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java
harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Timestamp.java
harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContext.java
Propchange: harmony/enhanced/classlib/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 19 21:47:38 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk:713674-727674
+/harmony/enhanced/classlib/trunk:713674-735919
Modified: harmony/enhanced/classlib/branches/java6/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/build.xml?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/build.xml Mon Jan 19 21:47:38 2009
@@ -20,12 +20,12 @@
====================================================================== -->
<project name="build-contribution" default="build" basedir=".">
<description>
- Build contributed source and lay out results in the required format
+ Build contributed source and lay out results in the required format
</description>
<target name="help">
<echo>
-Apache Harmony Ant Build
+Apache Harmony Classlibrary Build
Usage:
@@ -56,12 +56,17 @@
Display the common properties that are use in the ant build files.
-The 'build' and 'test' targets can be restricted to processing only
-a single module by defining the 'build.module' variable on the ant
-command line. For example, to run only the luni tests:
+The 'build' and 'test' targets can be configured to only build/test a single
+module by setting the 'build.module' property. For example, to run the tests for
+the "luni" module:
- ant -Dbuild.module=luni test
+ ant test -Dbuild.module=luni
+The 'test' target can further be configured to run a single test by setting
+the 'test.case' property. For example, to run a specific test in the "luni"
+module:
+
+ ant test -Dbuild.module=luni -Dtest.case=org.apache.harmony.luni.tests.java.lang.MathTest
</echo>
</target>
Modified: harmony/enhanced/classlib/branches/java6/modules/auth/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/META-INF/MANIFEST.MF?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/META-INF/MANIFEST.MF Mon Jan 19 21:47:38 2009
@@ -12,8 +12,8 @@
Bundle-ClassPath: .
Eclipse-JREBundle: true
Eclipse-ExtensibleAPI: true
-Import-Package: java.awt,
- java.awt.event,
+Import-Package: java.awt;resolution:=optional,
+ java.awt.event;resolution:=optional,
java.beans,
java.io,
java.lang,
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java Mon Jan 19 21:47:38 2009
@@ -55,6 +55,71 @@
// expected
}
+ @SuppressWarnings("unchecked")
+ private static Object internalInstantiate(ClassLoader cls, String beanName,
+ BeanContext context, Object initializer)
+ throws IOException, ClassNotFoundException {
+ Object result = null;
+
+ boolean deserialized = true;
+
+ ClassLoader loader = null;
+
+ // First try to load it from a serialization file.
+ String beanResourceName = getBeanResourceName(beanName);
+
+ InputStream is = (cls == null) ? ClassLoader
+ .getSystemResourceAsStream(beanResourceName) : cls
+ .getResourceAsStream(beanResourceName);
+
+ IOException serializationException = null;
+ if (is != null) {
+ try{
+ ObjectInputStream ois = (cls == null) ? new ObjectInputStream(is)
+ : new CustomizedObjectInputStream(is, cls);
+ result = ois.readObject();
+ }catch(IOException exception){
+ //Not loadable - remember this as we may throw it later.
+ serializationException = exception;
+ }
+ }
+
+ //If that did not work, try to instantiate it from the given classloader.
+ if (result == null) {
+ deserialized = false;
+ try {
+ loader = cls == null ? ClassLoader.getSystemClassLoader() : cls;
+ Class<?> c = Class.forName(beanName, true, loader);
+ result = c.newInstance();
+ } catch (Exception e) {
+ if (serializationException != null) {
+ throw serializationException;
+ }
+ throw new ClassNotFoundException(e.getClass() + ": " //$NON-NLS-1$
+ + e.getMessage());
+ }
+ }
+
+ if (result != null) {
+ // Applet specific initialization
+ boolean isApplet = false;
+ try {
+ isApplet = result instanceof Applet;
+ } catch (Throwable t) {
+ // Ignored - leave isApplet as false.
+ }
+
+ if (isApplet) {
+ appletLoaded((Applet) result, loader, beanName, context,
+ (AppletInitializer)initializer, deserialized);
+ }
+ if (null != context) {
+ context.add(result);
+ }
+ }
+ return result;
+ }
+
/**
* Obtains an instance of a JavaBean specified the bean name using the
* specified class loader.
@@ -72,7 +137,7 @@
*/
public static Object instantiate(ClassLoader loader, String name)
throws IOException, ClassNotFoundException {
- return instantiate(loader, name, null, null);
+ return internalInstantiate(loader, name, null, null);
}
/**
@@ -96,7 +161,7 @@
*/
public static Object instantiate(ClassLoader cls, String beanName,
BeanContext beanContext) throws IOException, ClassNotFoundException {
- return instantiate(cls, beanName, beanContext, null);
+ return internalInstantiate(cls, beanName, beanContext, null);
}
@@ -155,58 +220,7 @@
public static Object instantiate(ClassLoader cls, String beanName,
BeanContext context, AppletInitializer initializer)
throws IOException, ClassNotFoundException {
- Object result = null;
-
- boolean deserialized = true;
-
- ClassLoader loader = null;
-
- // First try to load it from a serialization file.
- String beanResourceName = getBeanResourceName(beanName);
-
- InputStream is = (cls == null) ? ClassLoader
- .getSystemResourceAsStream(beanResourceName) : cls
- .getResourceAsStream(beanResourceName);
-
- IOException serializationException = null;
- if (is != null) {
- try{
- ObjectInputStream ois = (cls == null) ? new ObjectInputStream(is)
- : new CustomizedObjectInputStream(is, cls);
- result = ois.readObject();
- }catch(IOException exception){
- //Not loadable - remember this as we may throw it later.
- serializationException = exception;
- }
- }
-
- //If that did not work, try to instantiate it from the given classloader.
- if (result == null) {
- deserialized = false;
- try {
- loader = cls == null ? ClassLoader.getSystemClassLoader() : cls;
- Class<?> c = Class.forName(beanName, true, loader);
- result = c.newInstance();
- } catch (Exception e) {
- if (serializationException != null) {
- throw serializationException;
- }
- throw new ClassNotFoundException(e.getClass() + ": " //$NON-NLS-1$
- + e.getMessage());
- }
- }
-
- if (result != null) {
- // Applet specific initialization
- if (result instanceof Applet) {
- appletLoaded((Applet) result, loader, beanName, context,
- initializer, deserialized);
- }
- if (null != context) {
- context.add(result);
- }
- }
- return result;
+ return internalInstantiate(cls, beanName, context, initializer);
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Introspector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Introspector.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Introspector.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Introspector.java Mon Jan 19 21:47:38 2009
@@ -300,7 +300,14 @@
beanInfoClassName = searchPath[i] + "." + beanInfoName; //$NON-NLS-1$
try{
theBeanInfo = loadBeanInfo(beanInfoClassName, beanClass);
- break;
+
+ // find the beanInfo of the given beanClass, check whether the
+ // beanInfo is consistent with the given beanClass
+ Class<?> beanClassOfBeanInfo = theBeanInfo.getBeanDescriptor()
+ .getBeanClass();
+ if (beanClassOfBeanInfo.equals(beanClass)) {
+ break;
+ }
}catch(Exception e){
//ignore, try next one
}
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=735939&r1=735938&r2=735939&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 Mon Jan 19 21:47:38 2009
@@ -576,13 +576,6 @@
this.listener = (listener == null) ? new DefaultExceptionListener()
: listener;
defaultClassLoader = cl;
-
- try {
- SAXParserFactory.newInstance().newSAXParser().parse(inputStream,
- new SAXHandler());
- } catch (Exception e) {
- this.listener.exceptionThrown(e);
- }
}
/**
@@ -623,6 +616,13 @@
*/
@SuppressWarnings("nls")
public Object readObject() {
+ try {
+ SAXParserFactory.newInstance().newSAXParser().parse(inputStream,
+ new SAXHandler());
+ } catch (Exception e) {
+ this.listener.exceptionThrown(e);
+ }
+
if (readObjIndex >= readObjs.size()) {
throw new ArrayIndexOutOfBoundsException("no more objects to read");
}
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java Mon Jan 19 21:47:38 2009
@@ -1649,6 +1649,46 @@
}
}
+ /*
+ * @test setBeanInfoSearchPath
+ *
+ * Change the sequence of the paths in Introspector.searchpaths, check
+ * whether the BeanInfo is consistent with the bean class
+ */
+ public void testSetBeanInfoSearchPath_SameClassesInDifferentPackage()
+ throws IntrospectionException {
+ // set the search path in the correct sequence
+ Introspector
+ .setBeanInfoSearchPath(new String[] {
+ "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info",
+ "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info", });
+
+ BeanInfo beanInfo = Introspector
+ .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+ BeanDescriptor beanDesc = beanInfo.getBeanDescriptor();
+
+ assertEquals(beanDesc.getName(), "mocksubject1");
+ assertEquals(
+ beanDesc.getBeanClass(),
+ org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+
+ // set the search path in the reverse sequence
+ Introspector
+ .setBeanInfoSearchPath(new String[] {
+ "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info",
+ "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info", });
+
+ beanInfo = Introspector
+ .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+ beanDesc = beanInfo.getBeanDescriptor();
+
+ assertEquals(beanDesc.getName(), "mocksubject1");
+ assertEquals(
+ beanDesc.getBeanClass(),
+ org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+
+ }
+
static class MockSecurity2 extends SecurityManager {
@Override
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=735939&r1=735938&r2=735939&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 Mon Jan 19 21:47:38 2009
@@ -430,6 +430,31 @@
assertEquals(o2, t2.getV());
}
+ public void testSetExceptionListener_Called() throws Exception {
+ class MockExceptionListener implements ExceptionListener {
+
+ private boolean isCalled = false;
+
+ public void exceptionThrown(Exception e) {
+ isCalled = true;
+ }
+
+ public boolean isCalled() {
+ return isCalled;
+ }
+ }
+
+ XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
+ "<java><string/>".getBytes("UTF-8")));
+ MockExceptionListener mockListener = new MockExceptionListener();
+ xmlDecoder.setExceptionListener(mockListener);
+
+ assertFalse(mockListener.isCalled());
+ // Real Parsing should occur in method of ReadObject rather constructor.
+ assertNotNull(xmlDecoder.readObject());
+ assertTrue(mockListener.isCalled());
+ }
+
public void testSetExceptionListener() {
XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
Object defaultL = dec.getExceptionListener();
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF Mon Jan 19 21:47:38 2009
@@ -11,7 +11,7 @@
Bundle-Version: 1.0.0
Bundle-ClassPath: .
Eclipse-JREBundle: true
-Import-Package: java.applet,
+Import-Package: java.applet;resolution:=optional,
java.awt;resolution:=optional,
java.beans;resolution:=optional,
java.io,
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java Mon Jan 19 21:47:38 2009
@@ -64,7 +64,15 @@
* @since 1.5
*/
public static final int SIZE = 32;
-
+
+ /*
+ * Progressively smaller decimal order of magnitude that can be represented
+ * by an instance of Integer. Used to help compute the String
+ * representation.
+ */
+ private static final int[] decimalScale = new int[] { 1000000000, 100000000,
+ 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1 };
+
/**
* The java.lang.Class that represents this class.
*/
@@ -510,12 +518,98 @@
* Answers a string containing characters in the range 0..9 which describe
* the decimal representation of the argument.
*
- * @param i
+ * @param value
* an int to get the representation of
* @return String the representation of the argument
*/
- public static String toString(int i) {
- return toString(i, 10);
+ public static String toString(int value) {
+ if (value == 0) {
+ return "0"; //$NON-NLS-1$
+ }
+
+ // Faster algorithm for smaller Integers
+ if (value < 1000 && value > -1000) {
+ char[] buffer = new char[4];
+ int positive_value = value < 0 ? -value : value;
+ int first_digit = 0;
+ if (value < 0) {
+ buffer[0] = '-';
+ first_digit++;
+ }
+ int last_digit = first_digit;
+ int quot = positive_value;
+ do {
+ int res = quot / 10;
+ int digit_value = quot - (res * 10);
+ digit_value += '0';
+ buffer[last_digit++] = (char) digit_value;
+ quot = res;
+ } while (quot != 0);
+
+ int count = last_digit--;
+ do {
+ char tmp = buffer[last_digit];
+ buffer[last_digit--] = buffer[first_digit];
+ buffer[first_digit++] = tmp;
+ } while (first_digit < last_digit);
+ return new String(0, count, buffer);
+ }
+ if (value == MIN_VALUE) {
+ return "-2147483648";//$NON-NLS-1$
+ }
+
+ char[] buffer = new char[11];
+ int positive_value = value < 0 ? -value : value;
+ byte first_digit = 0;
+ if (value < 0) {
+ buffer[0] = '-';
+ first_digit++;
+ }
+ byte last_digit = first_digit;
+ byte count;
+ int number;
+ boolean start = false;
+ for (int i = 0; i < 9; i++) {
+ count = 0;
+ if (positive_value < (number = decimalScale[i])) {
+ if (start) {
+ buffer[last_digit++] = '0';
+ }
+ continue;
+ }
+
+ if (i > 0) {
+ number = (decimalScale[i] << 3);
+ if (positive_value >= number) {
+ positive_value -= number;
+ count += 8;
+ }
+ number = (decimalScale[i] << 2);
+ if (positive_value >= number) {
+ positive_value -= number;
+ count += 4;
+ }
+ }
+ number = (decimalScale[i] << 1);
+ if (positive_value >= number) {
+ positive_value -= number;
+ count += 2;
+ }
+ if (positive_value >= decimalScale[i]) {
+ positive_value -= decimalScale[i];
+ count++;
+ }
+ if (count > 0 && !start) {
+ start = true;
+ }
+ if (start) {
+ buffer[last_digit++] = (char) (count + '0');
+ }
+ }
+
+ buffer[last_digit++] = (char) (positive_value + '0');
+ count = last_digit--;
+ return new String(0, count, buffer);
}
/**
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=735939&r1=735938&r2=735939&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 Mon Jan 19 21:47:38 2009
@@ -131,7 +131,7 @@
setActions(action);
actions = toCanonicalActionString(action);
// Use host since we are only checking for port presence
- parsePort(host);
+ parsePort(host, hostName);
}
/**
@@ -226,6 +226,7 @@
} else if (action.equals(actionNames[SP_ACCEPT])) {
actionsMask |= SP_ACCEPT;
} else if (action.equals(actionNames[SP_RESOLVE])) {
+ // do nothing
} else {
throw new IllegalArgumentException(Msg.getString("K0048", //$NON-NLS-1$
action));
@@ -281,70 +282,61 @@
public PermissionCollection newPermissionCollection() {
return new SocketPermissionCollection();
}
-
+
/**
- * Parses the port string into the lower and higher bound of the port range.
- *
+ * Parse the port, including the minPort, maxPort
+ * @param hostPort the host[:port] one
+ * @param host the host name we just get
+ * @throws IllegalArgumentException If the port is not a positive number or minPort
+ * is not less than or equal maxPort
*/
- private void parsePort(String hostString) throws IllegalArgumentException {
- int negidx = -1;
- int len = -1;
- int lastIdx = hostString.lastIndexOf(':');
- int idx = hostString.indexOf(':');
- int endOfIPv6Addr = hostString.lastIndexOf(']');
- if ((endOfIPv6Addr == -1) && (idx != lastIdx)) {
- // there are no square braces, but there are more than one ':' which
- // implies an IPv6 address with no port, or an illegal argument
- // check for valid IPv6 address
- if (Inet6Util.isValidIP6Address(hostString)) {
- return;
- }
- // throw an invalid argument exception
- throw new IllegalArgumentException(Msg.getString("K004a")); //$NON-NLS-1$
- }
- // if there is a colon and it occurs after the ']' then there is a port
- // to be parsed
- if ((lastIdx > -1) && (lastIdx > endOfIPv6Addr)) {
- try {
- len = hostString.length();
- // if hostString ends with ":*", such as "localhost:*"
- // the port range should be 0-65535
- if (hostString.endsWith(":*")) { //$NON-NLS-1$
- portMin = 0;
- portMax = 65535;
- return;
- }
- // look for a '-' after the colon
- negidx = hostString.indexOf('-', lastIdx);
- if (negidx == lastIdx + 1) {
- portMax = Integer.parseInt(hostString.substring(
- lastIdx + 2, len));
- } else {
- // A port range was provided
- if (negidx != -1 && (negidx != len - 1)) {
- portMin = Integer.parseInt(hostString.substring(
- lastIdx + 1, negidx));
- portMax = Integer.parseInt(hostString.substring(
- negidx + 1, len));
- } else {
- if (negidx == -1) {
- portMin = Integer.parseInt(hostString.substring(
- lastIdx + 1, len));
- portMax = portMin;
- } else {
- portMin = Integer.parseInt(hostString.substring(
- lastIdx + 1, negidx));
- }
- }
- }
- if (portMax < portMin) {
- throw new IllegalArgumentException(Msg.getString("K0049")); //$NON-NLS-1$
- }
-
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(Msg.getString("K004a")); //$NON-NLS-1$
- }
- }
+ private void parsePort(String hostPort, String host) throws IllegalArgumentException {
+ String port = hostPort.substring(host.length());
+ String emptyString = ""; //$NON-NLS-1$
+
+ if (emptyString.equals(port)) {
+ // Not specified
+ portMin = 80;
+ portMax = 80;
+ return;
+ }
+
+ if (":*".equals(port)) {
+ // The port range should be 0-65535
+ portMin = 0;
+ portMax = 65535;
+ return;
+ }
+
+ // Omit ':'
+ port = port.substring(1);
+ int negIdx = port.indexOf('-');
+ String strPortMin = emptyString;
+ String strPortMax = emptyString;
+ if (-1 == negIdx) {
+ // No neg mark, only one number
+ strPortMin = port;
+ strPortMax = port;
+ } else {
+ strPortMin = port.substring(0, negIdx);
+ strPortMax = port.substring(negIdx + 1);
+ if (emptyString.equals(strPortMin)) {
+ strPortMin = "0";
+ }
+ if (emptyString.equals(strPortMax)) {
+ strPortMax = "65535";
+ }
+ }
+ try {
+ portMin = Integer.valueOf(strPortMin).intValue();
+ portMax = Integer.valueOf(strPortMax).intValue();
+
+ if (portMin > portMax) {
+ throw new IllegalArgumentException(Msg.getString("K0049") + " " + port); //$NON-NLS-1$
+ }
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(Msg.getString("K004a") + " " + port); //$NON-NLS-1$
+ }
}
/**
@@ -384,13 +376,26 @@
try {
ipString = InetAddress.getHostNameInternal(hostName);
} catch (UnknownHostException e) {
+ // ignore
}
resolved = true;
}
return ipString;
}
+ /**
+ * Get the host part from the host[:port] one.
+ * The host should be
+ * host = (hostname | IPv4address | IPv6reference | IPv6 in full uncompressed form)
+ * The wildcard "*" may be included once in a DNS name host specification. If it is included,
+ * it must be in the leftmost position
+ *
+ * @param host
+ * @return
+ * @throws IllegalArgumentException if the host is invalid.
+ */
private String getHostString(String host) throws IllegalArgumentException {
+ host = host.trim();
int idx = -1;
idx = host.indexOf(':');
isPartialWild = (host.length() > 0 && host.charAt(0) == '*');
@@ -407,22 +412,46 @@
}
int lastIdx = host.lastIndexOf(':');
- if ((idx > -1) && (idx == lastIdx)) {
- host = host.substring(0, idx);
- } else {
- // likely host is or contains an IPv6 address
- if (lastIdx != -1) {
- if (Inet6Util.isValidIP6Address(host)) {
- return host.toLowerCase();
- } else if (Inet6Util.isValidIP6Address(host.substring(0,
- lastIdx))) {
- host = host.substring(0, lastIdx);
- } else {
- throw new IllegalArgumentException(Msg.getString("K004a")); //$NON-NLS-1$
+
+ if (idx == lastIdx) {
+ if (-1 != idx) {
+ // only one colon, should be port
+ host = host.substring(0, idx);
+ }
+ return host.toLowerCase();
+ }
+ // maybe ipv6
+ boolean isFirstBracket = (host.charAt(0) == '[');
+ if (!isFirstBracket) {
+ // No bracket, should be in full form
+ int colonNum = 0;
+ for (int i = 0; i < host.length(); ++i) {
+ if (host.charAt(i) == ':') {
+ colonNum++;
}
}
+ // Get rid of the colon before port
+ if (8 == colonNum) {
+ host = host.substring(0, lastIdx);
+ }
+ if (Inet6Util.isIP6AddressInFullForm(host)) {
+ return host.toLowerCase();
+ }
+ throw new IllegalArgumentException(Msg.getString("K004a") + " "
+ + host);
+ }
+ // forward bracket found
+ int bbracketIdx = host.indexOf(']');
+ if (-1 == bbracketIdx) {
+ // no back bracket found, wrong
+ throw new IllegalArgumentException(Msg.getString("K004a") + " "
+ + host);
+ }
+ host = host.substring(0, bbracketIdx + 1);
+ if (Inet6Util.isValidIP6Address(host)) {
+ return host.toLowerCase();
}
- return host.toLowerCase();
+ throw new IllegalArgumentException(Msg.getString("K004a") + " " + host);
}
/*
@@ -458,7 +487,7 @@
portMax = HIGHEST_PORT;
actionsMask = SP_RESOLVE;
hostName = getHostString(getName());
- parsePort(getName());
+ parsePort(getName(), hostName);
setActions(actions);
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java Mon Jan 19 21:47:38 2009
@@ -418,18 +418,16 @@
null, null, null, null, null);
}
} else {
- boolean exception = false;
+ boolean exception = packageObj.isSealed();
if (manifest != null) {
if (isSealed(manifest, packageName + "/")) {
exception = !packageObj
.isSealed(codeSourceUrl);
}
- } else {
- exception = packageObj.isSealed();
}
if (exception) {
throw new SecurityException(Msg
- .getString("K004c")); //$NON-NLS-1$
+ .getString("K0352", packageName)); //$NON-NLS-1$
}
}
}
@@ -915,9 +913,10 @@
return new URL("jar", "", //$NON-NLS-1$ //$NON-NLS-2$
-1, url.toString() + "!/"); //$NON-NLS-1$
}
+ // use jar protocol as the stream handler protocol
return new URL("jar", "", //$NON-NLS-1$ //$NON-NLS-2$
-1, url.toString() + "!/", //$NON-NLS-1$
- factory.createURLStreamHandler(protocol));
+ factory.createURLStreamHandler("jar"));//$NON-NLS-1$
}
/**
@@ -1039,6 +1038,7 @@
jarURL.toExternalForm() + "!/").openConnection(); //$NON-NLS-1$
JarFile jf = juc.getJarFile();
URLJarHandler jarH = new URLJarHandler(url, jarURL, jf, prefixName);
+
if (jarH.getIndex() == null) {
try {
Manifest manifest = jf.getManifest();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java Mon Jan 19 21:47:38 2009
@@ -138,7 +138,7 @@
* the number of milliseconds since Jan. 1, 1970 GMT
*/
public Date(long milliseconds) {
- this.setTime(milliseconds);
+ this.milliseconds = milliseconds;
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java Mon Jan 19 21:47:38 2009
@@ -1136,6 +1136,45 @@
} else {
output.append("1\r\n"); //$NON-NLS-1$
}
+ // add user-specified request headers if any
+ boolean hasContentLength = false;
+ for (int i = 0; i < reqHeader.length(); i++) {
+ String key = reqHeader.getKey(i);
+ if (key != null) {
+ String lKey = key.toLowerCase();
+ if ((os != null && !os.isChunked())
+ || (!lKey.equals("transfer-encoding") && !lKey //$NON-NLS-1$
+ .equals("content-length"))) { //$NON-NLS-1$
+ output.append(key);
+ String value = reqHeader.get(i);
+ /*
+ * duplicates are allowed under certain conditions see
+ * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
+ */
+ if (lKey.equals("content-length")) { //$NON-NLS-1$
+ hasContentLength = true;
+ /*
+ * if both setFixedLengthStreamingMode and
+ * content-length are set, use fixedContentLength first
+ */
+ if(fixedContentLength >= 0){
+ value = String.valueOf(fixedContentLength);
+ }
+ }
+ if (value != null) {
+ output.append(": "); //$NON-NLS-1$
+ output.append(value);
+ }
+ output.append("\r\n"); //$NON-NLS-1$
+ }
+ }
+ }
+ if (fixedContentLength >= 0 && !hasContentLength) {
+ output.append("content-length: "); //$NON-NLS-1$
+ output.append(String.valueOf(fixedContentLength));
+ output.append("\r\n"); //$NON-NLS-1$
+ }
+
if (reqHeader.get("User-Agent") == null) { //$NON-NLS-1$
output.append("User-Agent: "); //$NON-NLS-1$
String agent = getSystemProperty("http.agent"); //$NON-NLS-1$
@@ -1157,6 +1196,9 @@
}
output.append("\r\n"); //$NON-NLS-1$
}
+ if (reqHeader.get("Accept") == null) { //$NON-NLS-1$
+ output.append("Accept: *; */*\r\n"); //$NON-NLS-1$
+ }
if (httpVersion > 0 && reqHeader.get("Connection") == null) { //$NON-NLS-1$
output.append("Connection: Keep-Alive\r\n"); //$NON-NLS-1$
}
@@ -1176,43 +1218,6 @@
output.append("Transfer-Encoding: chunked\r\n"); //$NON-NLS-1$
}
}
-
- boolean hasContentLength = false;
- // then the user-specified request headers, if any
- for (int i = 0; i < reqHeader.length(); i++) {
- String key = reqHeader.getKey(i);
- if (key != null) {
- String lKey = key.toLowerCase();
- if ((os != null && !os.isChunked())
- || (!lKey.equals("transfer-encoding") && !lKey //$NON-NLS-1$
- .equals("content-length"))) { //$NON-NLS-1$
- output.append(key);
- output.append(": "); //$NON-NLS-1$
- /*
- * duplicates are allowed under certain conditions see
- * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
- */
- if (lKey.equals("content-length")) { //$NON-NLS-1$
- hasContentLength = true;
- /*
- * if both setFixedLengthStreamingMode and
- * content-length are set, use fixedContentLength first
- */
- output.append((fixedContentLength >= 0) ? String
- .valueOf(fixedContentLength)
- : reqHeader.get(i));
- } else {
- output.append(reqHeader.get(i));
- }
- output.append("\r\n"); //$NON-NLS-1$
- }
- }
- }
- if (fixedContentLength >= 0 && !hasContentLength) {
- output.append("content-length: "); //$NON-NLS-1$
- output.append(String.valueOf(fixedContentLength));
- output.append("\r\n"); //$NON-NLS-1$
- }
// end the headers
output.append("\r\n"); //$NON-NLS-1$
return output.toString().getBytes("ISO8859_1"); //$NON-NLS-1$
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties Mon Jan 19 21:47:38 2009
@@ -286,6 +286,7 @@
K034d=method has not been implemented yet
K034e=Build rules empty
K0351=format is null
+K0352=package is sealed
KA000=Line too long
KA001=Argument must not be null
KA002=Unshared read of back reference
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java Mon Jan 19 21:47:38 2009
@@ -293,6 +293,18 @@
+ ((value >> 8) & 0xff) + "." + (value & 0xff);
}
+ public static boolean isIP6AddressInFullForm(String ipAddress) {
+ if (isValidIP6Address(ipAddress)) {
+ int doubleColonIndex = ipAddress.indexOf("::");
+ if (doubleColonIndex >= 0) {
+ // Simplified form which contains ::
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
public static boolean isValidIP6Address(String ipAddress) {
int length = ipAddress.length();
boolean doubleColon = false;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile Mon Jan 19 21:47:38 2009
@@ -46,8 +46,10 @@
# OPT is overriden except on zOS (fpic, for example, is not an option on zOS)
ifneq ($(HY_OS),zos)
+ifneq ($(HY_OS),aix)
OPT = -O0 -ffloat-store -fpic
endif
+endif
DEFINES += -D_IEEE_LIBM
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/luniglob.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/luniglob.c?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/luniglob.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/luniglob.c Mon Jan 19 21:47:38 2009
@@ -162,21 +162,6 @@
}
}
- /* Set default PreferencesFactory implementation */
- (*vmInterface)->GetSystemProperty (vmInterface, "java.util.prefs.PreferencesFactory", &propVal);
- if (propVal == NULL) {
- propRes = (*vmInterface)->SetSystemProperty (vmInterface,
- "java.util.prefs.PreferencesFactory",
-#ifdef _WIN32
- "java.util.prefs.RegistryPreferencesFactoryImpl");
-#else
- "java.util.prefs.FilePreferencesFactoryImpl");
-#endif
- if (VMI_ERROR_NONE != propRes) {
- /* goto fail2; */
- }
- }
-
/* Prefer Xalan compiler for better performance, see HARMONY-3209. */
(*vmInterface)->GetSystemProperty (vmInterface, "javax.xml.transform.TransformerFactory", &propVal);
if (propVal == NULL) {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile Mon Jan 19 21:47:38 2009
@@ -21,8 +21,10 @@
# CFLAGS += -fpic -Wall -Werror
ifneq ($(HY_OS),zos)
+ifneq ($(HY_OS),aix)
CFLAGS += -Wall
endif
+endif
BUILDFILES = \
$(SHAREDSUB)luni_copyright.o $(SHAREDSUB)file.o procimpl.o \
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java Mon Jan 19 21:47:38 2009
@@ -915,6 +915,38 @@
System.setSecurityManager(null);
}
}
+
+ /*
+ * @test HttpURLConnection.setRequestProperty
+ */
+ public void testSetRequestProperty() throws Exception {
+ MockHTTPServer httpServer = new MockHTTPServer(
+ "HTTP Server for User-Specified Request Property", 2);
+ httpServer.start();
+ synchronized (bound) {
+ if (!httpServer.started) {
+ bound.wait(5000);
+ }
+ }
+
+ HttpURLConnection urlConnection = (HttpURLConnection) new URL(
+ "http://localhost:" + httpServer.port()).openConnection();
+ assertEquals(0, urlConnection.getRequestProperties().size());
+
+ final String PROPERTY1 = "Accept";
+ final String PROPERTY2 = "Connection";
+ urlConnection.setRequestProperty(PROPERTY1, null);
+ urlConnection.setRequestProperty(PROPERTY1, null);
+ urlConnection.setRequestProperty(PROPERTY2, "keep-alive");
+ assertEquals(2, urlConnection.getRequestProperties().size());
+ assertNull(urlConnection.getRequestProperty(PROPERTY1));
+ assertEquals("keep-alive", urlConnection.getRequestProperty(PROPERTY2));
+
+ urlConnection.setRequestProperty(PROPERTY1, "/");
+ urlConnection.setRequestProperty(PROPERTY2, null);
+ assertEquals("/", urlConnection.getRequestProperty(PROPERTY1));
+ assertNull(urlConnection.getRequestProperty(PROPERTY2));
+ }
private static class MySecurityManager extends SecurityManager {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/PackageTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/PackageTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/PackageTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/PackageTest.java Mon Jan 19 21:47:38 2009
@@ -17,7 +17,7 @@
package org.apache.harmony.luni.tests.java.lang;
import java.io.File;
-import java.lang.reflect.Method;
+import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
@@ -290,4 +290,101 @@
assertTrue("Package toString returns wrong string", p.toString()
.length() > 0);
}
+
+ public void test_SealedPackage_forName() throws Exception {
+ Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
+ Support_Resources.copyFile(resources, "Package", "hyts_d.jar");
+ Support_Resources.copyFile(resources, "Package", "hyts_d1.jar");
+ Support_Resources.copyFile(resources, "Package", "hyts_d2.jar");
+
+ URL resourceURL1 = new URL("file:/" + resPath + "/Package/hyts_c.jar");
+ URL resourceURL2 = new URL("file:/" + resPath + "/Package/hyts_d.jar");
+ URL resourceURL3 = new URL("file:/" + resPath + "/Package/hyts_d1.jar");
+ URL resourceURL4 = new URL("file:/" + resPath + "/Package/hyts_d2.jar");
+ URL resourceURL5 = new URL("file:/" + resPath + "/");
+
+ URLClassLoader uclClassLoader;
+ // load from the sealed jar, then an unsealed jar with no manifest
+ uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
+ resourceURL2 }, null);
+ Class.forName("p.C", true, uclClassLoader);
+ try {
+ Class.forName("p.D", true, uclClassLoader);
+ fail("should throw SecurityException");
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ // setup for next test
+ Support_Resources.copyFile(resources, "p", "");
+ InputStream in = uclClassLoader.getResourceAsStream("p/D.class");
+ Support_Resources.copyLocalFileto(new File(resources.toString(),
+ "p/D.class"), in);
+
+ // load from a sealed jar, then the directory
+ uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
+ resourceURL5 }, null);
+ Class.forName("p.C", true, uclClassLoader);
+ try {
+ Class.forName("p.D", true, uclClassLoader);
+ fail("should throw SecurityException");
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ // load from a directory, then the sealed jar
+ uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
+ resourceURL5 }, null);
+ Class.forName("p.D", true, uclClassLoader);
+ try {
+ Class.forName("p.C", true, uclClassLoader);
+ fail("should throw SecurityException");
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ // load from an unsealed jar with no manifest, then the sealed jar
+ uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
+ resourceURL2 }, null);
+ Class.forName("p.D", true, uclClassLoader);
+ try {
+ Class.forName("p.C", true, uclClassLoader);
+ fail("should throw SecurityException");
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ // load from an unsealed jar with a manifest, then the sealed jar
+ uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
+ resourceURL3 }, null);
+ Class.forName("p.C", true, uclClassLoader);
+ try {
+ Class.forName("p.D", true, uclClassLoader);
+ fail("should throw SecurityException");
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ // load from an sealed jar, then the unsealed jar with a manifest
+ uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
+ resourceURL3 }, null);
+ Class.forName("p.D", true, uclClassLoader);
+ try {
+ Class.forName("p.C", true, uclClassLoader);
+ fail("should throw SecurityException");
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ // load from the sealed jar, then another sealed jar
+ uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
+ resourceURL4 }, null);
+ Class.forName("p.C", true, uclClassLoader);
+ try {
+ Class.forName("p.D", true, uclClassLoader);
+ fail("should throw SecurityException");
+ } catch (SecurityException e) {
+ // Expected
+ }
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java Mon Jan 19 21:47:38 2009
@@ -204,4 +204,33 @@
SerializationTest.verifySelf(permission);
}
+
+ public void test_ConstructorLjava_lang_StringLjava_lang_String_subtestIPv6() {
+ String[] goodTestStrings = {
+ "12334.0.0.01", "[fe80::1]",
+ "[FE80:0000:0000:0000:0000:0000:0000:0001]:80",
+ "[::ffff]:80-82", "[ffff::]:80-82", "[fe80::1]:80",
+ "FE80:0000:0000:0000:0000:0000:0000:0001",
+ "FE80:0000:0000:0000:0000:0000:0000:0001:80"
+ };
+ String[] badTestStrings = {"someName:withColonInit:80", "fg80::1", "[ffff:::80-82]",
+ ":[:fff]:80", "FE80:0000:0000:0000:0000:0000:0000:0001:80:82", "FE80::1"
+ };
+
+ for (int i=0; i < goodTestStrings.length; i++) {
+ try {
+ SocketPermission sp = new SocketPermission(goodTestStrings[i], "connect");
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ fail("SocketPermission named: " + goodTestStrings[i] + " failed construction: " + e.getMessage());
+ }
+ }
+
+ for (int i=0; i < badTestStrings.length; i++) {
+ try {
+ SocketPermission sp = new SocketPermission(badTestStrings[i], "connect");
+ fail("SocketPermission named: " + badTestStrings[i] + " should have thrown an IllegalArgumentException on construction");
+ } catch (IllegalArgumentException e) {}
+ }
+ }
}
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=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java Mon Jan 19 21:47:38 2009
@@ -59,6 +59,16 @@
// Test for method java.util.ArrayList(int)
ArrayList al = new ArrayList(5);
assertEquals("Incorrect arrayList created", 0, al.size());
+
+ al = new ArrayList(0);
+ assertEquals("Incorrect arrayList created", 0, al.size());
+
+ try {
+ al = new ArrayList(-1);
+ fail("Should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Excepted
+ }
}
/**
@@ -92,9 +102,68 @@
assertNull("Should have returned null", alist.get(25));
assertTrue("Should have returned the old item from slot 25", alist
.get(26) == oldItem);
+
+ alist.add(0, o = new Object());
+ assertEquals("Failed to add Object", alist.get(0), o);
+ assertEquals(alist.get(1), objArray[0]);
+ assertEquals(alist.get(2), objArray[1]);
+
+ oldItem = alist.get(0);
+ alist.add(0, null);
+ assertNull("Should have returned null", alist.get(0));
+ assertEquals("Should have returned the old item from slot 0", alist
+ .get(1), oldItem);
+
+ try {
+ alist.add(-1, new Object());
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ alist.add(-1, null);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ alist.add(alist.size() + 1, new Object());
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ alist.add(alist.size() + 1, null);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
+ * @tests java.util.ArrayList#add(int, java.lang.Object)
+ */
+ public void test_addILjava_lang_Object_2() {
+ Object o = new Object();
+ int size = alist.size();
+ alist.add(size, o);
+ assertEquals("Failed to add Object", alist.get(size), o);
+ assertEquals(alist.get(size - 2), objArray[size - 2]);
+ assertEquals(alist.get(size - 1), objArray[size - 1]);
+
+ alist.remove(size);
+
+ size = alist.size();
+ alist.add(size, null);
+ assertNull("Should have returned null", alist.get(size));
+ assertEquals(alist.get(size - 2), objArray[size - 2]);
+ assertEquals(alist.get(size - 1), objArray[size - 1]);
+ }
+
+ /**
* @tests java.util.ArrayList#add(java.lang.Object)
*/
public void test_addLjava_lang_Object() {
@@ -209,6 +278,48 @@
assertEquals(strings[i], list1.get(i + integers.length - 1));
}
}
+
+ /**
+ * @tests java.util.ArrayList#addAll(int, java.util.Collection)
+ */
+ public void test_addAllILjava_util_Collection_3() {
+ ArrayList obj = new ArrayList();
+ obj.addAll(0, obj);
+ obj.addAll(obj.size(), obj);
+ try {
+ obj.addAll(-1, obj);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ obj.addAll(obj.size() + 1, obj);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ obj.addAll(0, null);
+ fail("Should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Excepted
+ }
+
+ try {
+ obj.addAll(obj.size() + 1, null);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ obj.addAll((int) -1, (Collection) null);
+ fail("IndexOutOfBoundsException expected");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ }
public void test_addAllCollectionOfQextendsE() {
// Regression for HARMONY-539
@@ -261,6 +372,13 @@
assertTrue("Item at slot 103 is wrong: " + alist.get(102), alist
.get(102) == i.next());
+ try {
+ alist.addAll(null);
+ fail("Should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Excepted
+ }
+
// Regression test for Harmony-3481
ArrayList<Integer> originalList = new ArrayList<Integer>(12);
for (int j = 0; j < 12; j++) {
@@ -445,6 +563,58 @@
}
/**
+ * @tests {@link java.util.ArrayList#removeRange(int, int)}
+ */
+ public void test_removeRange() {
+ MockArrayList mylist = new MockArrayList();
+ mylist.removeRange(0, 0);
+
+ try {
+ mylist.removeRange(0, 1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ int[] data = { 1, 2, 3 };
+ for (int i = 0; i < data.length; i++) {
+ mylist.add(i, data[i]);
+ }
+
+ mylist.removeRange(0, 1);
+ assertEquals(data[1], mylist.get(0));
+ assertEquals(data[2], mylist.get(1));
+
+ try {
+ mylist.removeRange(-1, 1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ mylist.removeRange(0, -1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ mylist.removeRange(1, 0);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ mylist.removeRange(2, 1);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+ }
+
+ /**
* @tests java.util.ArrayList#remove(int)
*/
public void test_removeI() {
@@ -504,6 +674,38 @@
assertNull("Setting to null did not work", alist.get(50));
assertTrue("Setting increased the list's size to: " + alist.size(),
alist.size() == 100);
+
+ obj = new Object();
+ alist.set(0, obj);
+ assertTrue("Failed to set object", alist.get(0) == obj);
+
+ try {
+ alist.set(-1, obj);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ alist.set(alist.size(), obj);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ alist.set(-1, null);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ alist.set(alist.size(), null);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -674,6 +876,10 @@
public int size() {
return 0;
}
+
+ public void removeRange(int start, int end) {
+ super.removeRange(start, end);
+ }
}
public void test_subclassing() {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.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/DateTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java Mon Jan 19 21:47:38 2009
@@ -23,7 +23,23 @@
import java.util.TimeZone;
public class DateTest extends junit.framework.TestCase {
-
+
+ static class MockDate extends Date{
+ private String holiday;
+
+ public MockDate(long theTime) {
+ super(theTime);
+ holiday = "Christmas";
+ }
+
+ // Constructor should not call this public API,
+ // since it may be overrided to use variables uninitialized.
+ public void setTime(long theTime){
+ super.setTime(theTime);
+ holiday.hashCode();
+ }
+ }
+
/**
* @tests java.util.Date#Date()
*/
@@ -91,7 +107,8 @@
*/
public void test_ConstructorJ() {
// Test for method java.util.Date(long)
- assertTrue("Used to test", true);
+ Date date = new MockDate(1000L);
+ assertNotNull(date);
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.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/LinkedListTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java Mon Jan 19 21:47:38 2009
@@ -91,6 +91,34 @@
ll.get(51) == objArray[50] && (ll.get(52) == objArray[51]));
ll.add(50, null);
assertNull("Did not add null correctly", ll.get(50));
+
+ try {
+ ll.add(-1, "Test");
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ ll.add(-1, null);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ ll.add(ll.size() + 1, "Test");
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
+
+ try {
+ ll.add(ll.size() + 1, null);
+ fail("Should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Excepted
+ }
}
/**
@@ -136,6 +164,13 @@
assertEquals("d) List w/nulls not added correctly",
"Booga", ll.get(53));
assertNull("e) List w/nulls not added correctly", ll.get(54));
+
+ try {
+ ll.addAll(50, null);
+ fail("Should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Excepted
+ }
}
/**
@@ -185,6 +220,13 @@
assertEquals("d) List w/nulls not added correctly",
"Booga", ll.get(203));
assertNull("e) List w/nulls not added correctly", ll.get(204));
+
+ try {
+ ll.addAll(null);
+ fail("Should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Excepted
+ }
}
/**
@@ -265,6 +307,18 @@
} catch (IndexOutOfBoundsException e) {
}
}
+
+ /**
+ * @tests {@link java.util.LinkedList#peek()}
+ */
+ public void test_peek() {
+ LinkedList list = new LinkedList();
+
+ assertNull("Should return null if this list is empty", list.peek());
+
+ assertEquals("Returned incorrect first element", ll.peek(),objArray[0]);
+ assertEquals("Peek remove the head (first element) of this list", ll.getFirst(), objArray[0]);
+ }
/**
* @tests java.util.LinkedList#getFirst()
@@ -273,6 +327,14 @@
// Test for method java.lang.Object java.util.LinkedList.getFirst()
assertTrue("Returned incorrect first element", ll.getFirst().equals(
objArray[0]));
+
+ LinkedList list = new LinkedList();
+ try {
+ list.getFirst();
+ fail("Should throw NoSuchElementException");
+ } catch (NoSuchElementException e) {
+ // Excepted
+ }
}
/**
@@ -282,6 +344,14 @@
// Test for method java.lang.Object java.util.LinkedList.getLast()
assertTrue("Returned incorrect first element", ll.getLast().equals(
objArray[objArray.length - 1]));
+
+ LinkedList list = new LinkedList();
+ try {
+ list.getLast();
+ fail("Should throw NoSuchElementException");
+ } catch (NoSuchElementException e) {
+ // Excepted
+ }
}
/**
@@ -405,6 +475,14 @@
ll.removeFirst();
assertTrue("Failed to remove first element",
ll.getFirst() != objArray[0]);
+
+ LinkedList list = new LinkedList();
+ try {
+ list.removeFirst();
+ fail("Should throw NoSuchElementException");
+ } catch (NoSuchElementException e) {
+ // Excepted
+ }
}
/**
@@ -415,6 +493,14 @@
ll.removeLast();
assertTrue("Failed to remove last element",
ll.getLast() != objArray[objArray.length - 1]);
+
+ LinkedList list = new LinkedList();
+ try {
+ list.removeLast();
+ fail("Should throw NoSuchElementException");
+ } catch (NoSuchElementException e) {
+ // Excepted
+ }
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.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/ResourceBundleTest.java?rev=735939&r1=735938&r2=735939&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java Mon Jan 19 21:47:38 2009
@@ -360,7 +360,7 @@
ResourceBundle
.getBundle("org.apache.harmony.luni.tests.java.util.ResourceBundleTest$GetBundleTest");
}
- };
+ }
/**
* @tests java.util.ResourceBundle#getBundle(java.lang.String)