[jira] Created: (HARMONY-181) 3 missing getChannel() methods in java.net package
3 missing getChannel() methods in java.net package -- Key: HARMONY-181 URL: http://issues.apache.org/jira/browse/HARMONY-181 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to J2SE 1.5 and 1.4.2 specifications there should be public methods java.net.DatagramSocket.getChannel(), java.net.ServerSocket.getChannel(), java.net.Socket.getChannel() which are missed. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-73) java.net.InetAddress.getLocalHost() returns wrong host name for loopback address
[ http://issues.apache.org/jira/browse/HARMONY-73?page=comments#action_12368875 ] Svetlana Samoilenko commented on HARMONY-73: Tim/Paulex, thanks, bug is not reproducible with latest sources. java.net.InetAddress.getLocalHost() returns wrong host name for loopback address - Key: HARMONY-73 URL: http://issues.apache.org/jira/browse/HARMONY-73 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Priority: Minor Attachments: InetAddress.patch J2se 1.4.2 and 5.0 specifications for java.net.InetAddress.getLocalHost() read, that if there is a security manager, its checkConnect method is called with the local host name and -1 as its arguments to see if the operation is allowed. If the operation is not allowed, an InetAddress representing the loopback address is returned as hostname/hostaddress (as followed from toString() specification). The test listed below shows that the returned loopback address has wrong hostname, 127.0.0.1 instead of loopback. Inet_SecurityManager class is called twice and therefore host name is substituted with hostaddress address. Code to reproduce: import java.net.*; public class test2 { public static void main(String[] args) { try { System.setSecurityManager(new Inet_SecurityManager()); System.out.println(Loopback address = + InetAddress.getLocalHost()); } catch (Exception e){ System.out.println(Unexpected exception = + e); }; } } class Inet_SecurityManager extends SecurityManager { public void checkConnect(String host, int port) { super.checkConnect(host,port); throw new SecurityException(); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Inet_SecurityManager :host= nswssamoil1 Inet_SecurityManager :port= -1 Loopback address = localhost/127.0.0.1 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. Inet_SecurityManager :host= nswssamoil1 Inet_SecurityManager :port= -1 Inet_SecurityManager :host= localhost Inet_SecurityManager :port= -1 Loopback address = 127.0.0.1/127.0.0.1 Suggested junit test case: InetAddressTest.java - import java.net.*; import junit.framework.*; public class InetAddressTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InetAddress.class); } public void test_getLocalHost() { try{ System.setSecurityManager(new Inet_SecurityManager()); String hostname=InetAddress.getLocalHost().getHostName(); assertEquals(localhost, hostname); } catch (Exception e){ fail(Unexpected exception = + e); }; } } class Inet_SecurityManager extends SecurityManager { public void checkConnect(String host, int port) { super.checkConnect(host,port); throw new SecurityException(); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-102) java.util.Date.parse(String) throws java.lang.IllegalArgumentException for legal string
[ http://issues.apache.org/jira/browse/HARMONY-102?page=comments#action_12368877 ] Svetlana Samoilenko commented on HARMONY-102: - Vladimir, thank you, I can't reproduce the bug with latest sources. java.util.Date.parse(String) throws java.lang.IllegalArgumentException for legal string Key: HARMONY-102 URL: http://issues.apache.org/jira/browse/HARMONY-102 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison Attachments: fix102.txt According to 1.4.2 and 1.5 specifications for java.util.Date(String s) IllegalArgumentException is thrown if attempt to interpret the string s as a representation of a date and time is fails. Harmony throws IllegalArgumentException on legal string: Sat, 1 Jan 1970 +0130 00:00:00. Code to reproduce: import java.util.Date; public class test2 { public static void main(String[] args) { long date = Date.parse(Sat, 1 Jan 1970 +0130 00:00:00); System.out.println(date = + date); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) date =-540 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IllegalArgumentException at java.util.Date.parse(Date.java:404) at test2.main(test2.java:4) Suggested junit test case: DateTest.java - import junit.framework.*; import java.util.Date; public class DateTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(DateTest.class); } public void test_parse () { assertEquals(-540, Date.parse(Sat, 1 Jan 1970 +0130 00:00:00)); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-98) java.util.BitSet.clear(int toIndex,int fromIndex) throws unexpected IndexOutOfBoundsException when toIndex=fromIndex
[ http://issues.apache.org/jira/browse/HARMONY-98?page=comments#action_12368879 ] Svetlana Samoilenko commented on HARMONY-98: Tim, thanks, all works fine with with latest sources. java.util.BitSet.clear(int toIndex,int fromIndex) throws unexpected IndexOutOfBoundsException when toIndex=fromIndex Key: HARMONY-98 URL: http://issues.apache.org/jira/browse/HARMONY-98 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison Attachments: fix.txt, fix_hrm-98.txt According to 1.4.2 and 1.5 specification java.util.BitSet.clear(int,int) throws IndexOutOfBoundsException - if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. Harmony throws IndexOutOfBoundsException if toIndex=fromIndex. Code to reproduce: import java.util.BitSet; public class test2 { public static void main(String[] args) { BitSet set = new BitSet(); for(int i=0; i 20; i++) { set.set(i); } set.clear(10,10); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IndexOutOfBoundsException: Negative index specified at java.util.BitSet.clear(BitSet.java:423) at test2.main(test2.java:16) Suggested fix in attachment. Suggested junit test case: BitSetTest.java - import junit.framework.*; import java.util.BitSet; public class BitSetTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(BitSetTest.class); } public void test_clear() { BitSet set = new BitSet(); for(int i=0; i 20; i++) { set.set(i); } set.clear(10,10); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-94) java.util.Collections.binarySearch(List, Object, Comparator c) throws NPE when c is null
[ http://issues.apache.org/jira/browse/HARMONY-94?page=comments#action_12368880 ] Svetlana Samoilenko commented on HARMONY-94: Tim, thank you, I can't reproduce the bug with latest sources. java.util.Collections.binarySearch(List, Object, Comparator c) throws NPE when c is null Key: HARMONY-94 URL: http://issues.apache.org/jira/browse/HARMONY-94 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 and 1.5 specification for java.util.Collections.binarySearch(List, Object, Comparator c) method null value of Comparator c indicates, that the elements' natural ordering should be used. Harmony throws NPE in this case that contradicts specification. Code to reproduce: import java.util.*; public class test2 { public static void main(String args[]){ LinkedList lst = new LinkedList(); lst.add(new Integer(30)); Collections.sort(lst, null); int i = Collections.binarySearch(lst, new Integer(2), null); System.out.println(Index of search key = + i); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Index of search key =-1 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.NullPointerException at java.util.Collections.binarySearch(Collections.java:1347) at test2.main(test2.java:8) Suggected fix: Index: trunk/modules/luni/src/main/java/java/util/Collections.java === --- trunk/modules/luni/src/main/java/java/util/Collections.java (revision 377385) +++ trunk/modules/luni/src/main/java/java/util/Collections.java (working copy) @@ -1340,6 +1340,9 @@ */ public static int binarySearch(List list, Object object, Comparator comparator) { +if ( comparator== null) { +return Collections.binarySearch(list, object); +} if (!(list instanceof RandomAccess)) { ListIterator it = list.listIterator(); while (it.hasNext()) { Suggested junit test case: CollectionsTest.java - import junit.framework.*; import java.util.*; public class CollectionsTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CollectionsTest.class); } public void test_binarySearch () { LinkedList lst = new LinkedList(); lst.add(new Integer(30)); Collections.sort(lst, null); assertEquals(-1, Collections.binarySearch(lst, new Integer(2), null)); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-93) some methods in java.util.Collections don't throw NPE when the parameter is null
[ http://issues.apache.org/jira/browse/HARMONY-93?page=comments#action_12368881 ] Svetlana Samoilenko commented on HARMONY-93: Tim, thank you, I can't reproduce the bug with latest sources. some methods in java.util.Collections don't throw NPE when the parameter is null - Key: HARMONY-93 URL: http://issues.apache.org/jira/browse/HARMONY-93 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison Attachments: CollectionsTest.java, fix.txt According to j2se 1.4.2 and 1.5 specification for the Collections class The methods of this class all throw a NullPointerException if the collections provided to them are null. Harmony does not throw NPE for some methods. Code to reproduce: import java.util.*; public class test2 { public static void main(String [] args) { SortedMap m = null; Map map=null; Set set=null; SortedSet sortedset=null; SortedMap sortedmap =null; Collection col=null; try { Collections.synchronizedCollection(col); System.out.println(synchronizedCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedMap(sortedmap); System.out.println(synchronizedSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedMap(map); System.out.println(synchronizedMap(map) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSet(set); System.out.println(synchronizedSet(set) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedSet(sortedset); System.out.println(synchronizedSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableCollection(col); System.out.println(unmodifiableCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableMap(map); System.out.println(unmodifiableMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSet(set); System.out.println(unmodifiableSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedMap(sortedmap); System.out.println(unmodifiableSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedSet(sortedset); System.out.println(unmodifiableSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. synchronizedCollection(null) must throw NPE synchronizedSortedMap(null) must throw NPE synchronizedMap(map) must throw NPE synchronizedSet(set) must throw NPE synchronizedSortedSet(null) must throw NPE unmodifiableCollection(null) must throw NPE unmodifiableMap(null) must throw NPE unmodifiableSet(null) must throw NPE unmodifiableSortedMap(null) must throw NPE
[jira] Commented: (HARMONY-64) java.nio.charset.Charset.forName(String name) does not throw UnsupportedCharsetException if valid name starts with x-
[ http://issues.apache.org/jira/browse/HARMONY-64?page=comments#action_12367029 ] Svetlana Samoilenko commented on HARMONY-64: Tim, I have no objection. Let's wait. java.nio.charset.Charset.forName(String name) does not throw UnsupportedCharsetException if valid name starts with x- --- Key: HARMONY-64 URL: http://issues.apache.org/jira/browse/HARMONY-64 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison Attachments: ICUInterface34.dll, libICUInterface34.so According to j2se 1.4.2 specification for Charset forName(String charsetName) the method must throw UnsupportedCharsetException if no support for the named charset is available in this instance of the Java virtual machine. The method does not throw exception if a unsupported name started with x-. For example, the method throws an exception for not supported name xyz, but does not for x-yz. Code to reproduce: import java.nio.charset.*; public class test2 { public static void main (String[] args) { try{ Charset ch=Charset.forName(x-yz); System.out.println(***BAD. UnsupportedCharsetException must be thrown instead of creating +ch); } catch (UnsupportedCharsetException e) { System.out.println(***OK. Expected UnsupportedCharsetException + e); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***OK. Expected UnsupportedCharsetException java.nio.charset.UnsupportedCharsetException: x-yz C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. ***BAD. UnsupportedCharsetException must be thrown instead of creating Charset[x-yz] Suggested junit test case: CharsetTest.java - import java.nio.charset.*; import junit.framework.*; public class CharsetTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CharsetTest.class); } public void test_forName() { try { Charset ch=Charset.forName(x-yz); fail(Assert 0: UnsupportedCharsetException must be thrown instead of creating: + ch); } catch (UnsupportedCharsetException e) { } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.
[ http://issues.apache.org/jira/browse/HARMONY-67?page=comments#action_12366771 ] Svetlana Samoilenko commented on HARMONY-67: Tim, I agree with Vladimir, this condition cs.newDecoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE).decode(bb) is correct, it is compatibility issue. java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets. --- Key: HARMONY-67 URL: http://issues.apache.org/jira/browse/HARMONY-67 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 specification for Charset.decode(ByteBuffer b) the method must not throw any exceptions. The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following: UTF-16BE, UTF-16LE, UTF-16. BEA does not throw any exceptions. Code to reproduce: import java.nio.charset.Charset; import java.nio.ByteBuffer; import java.nio.CharBuffer; public class test2 { public static void main(String[] args) throws Exception { byte[] b = new byte[] {(byte)1}; ByteBuffer buf= ByteBuffer.wrap(b); CharBuffer charbuf=Charset.forName(UTF-16).decode(buf); System.out.println(CharBuffer.length()=+ charbuf.length()); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) CharBuffer.length()=0 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.nio.BufferOverflowException at java.nio.CharBuffer.put(CharBuffer.java:662) at java.nio.CharBuffer.put(CharBuffer.java:629) at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) at java.nio.charset.Charset.decode(Charset.java:630) at test2.main(test2.java:8) Suggested junit test case: CharsetTest.java - import java.nio.charset.Charset; import java.nio.ByteBuffer; import java.nio.CharBuffer; import junit.framework.*; public class CharsetTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CharsetTest.class); } public void test_decode() { byte[] b = new byte[] {(byte)1}; ByteBuffer buf= ByteBuffer.wrap(b); CharBuffer charbuf=Charset.forName(UTF-16).decode(buf); assertEquals(Assert 0: charset UTF-16,0,charbuf.length()); charbuf=Charset.forName(UTF-16BE).decode(buf); assertEquals(Assert 1: charset UTF-16BE,0, charbuf.length()); charbuf=Charset.forName(UTF-16LE).decode(buf); assertEquals(Assert 2: charset UTF16LE,0, charbuf.length()); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-101) NPE in java.util.regex.Pattern.compile()
NPE in java.util.regex.Pattern.compile() Key: HARMONY-101 URL: http://issues.apache.org/jira/browse/HARMONY-101 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to 1.4.2 and 1.5 specifications for java.util.regex.Pattern.matches(String regex,CharSequence input) An invocation of this convenience method of the form Pattern.matches(regex, input); behaves in exactly the same way as the expression Pattern.compile(regex).matcher(input).matches() Harmony throws unspecified NPE for Pattern.compile and returns false instead of true for Pattern.matches(). Code to reproduce: import java.util.regex.Pattern; public class test2 { public static void main(String[] args) { System.out.println(boolean is true=+Pattern.matches([,\\p{Punct}], ,)); System.out.println(boolean is true=+Pattern.compile([,\\p{Punct}]).matcher(,).matches()); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) boolean is true=true boolean is true=true C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. boolean is true=false java.lang.NullPointerException at test2.main(test2.java:5) Suggested junit test case: PatternTest.java - import junit.framework.*; import java.util.regex.Pattern; public class PatternTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(PatternTest.class); } public void test_compile () { assertTrue(Pattern.matches([,\\p{Punct}], ,)); assertTrue(Pattern.compile([,\\p{Punct}]).matcher(,).matches()); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-102) java.util.Date.parse(String) throws java.lang.IllegalArgumentException for legal string
java.util.Date.parse(String) throws java.lang.IllegalArgumentException for legal string Key: HARMONY-102 URL: http://issues.apache.org/jira/browse/HARMONY-102 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to 1.4.2 and 1.5 specifications for java.util.Date(String s) IllegalArgumentException is thrown if attempt to interpret the string s as a representation of a date and time is fails. Harmony throws IllegalArgumentException on legal string: Sat, 1 Jan 1970 +0130 00:00:00. Code to reproduce: import java.util.Date; public class test2 { public static void main(String[] args) { long date = Date.parse(Sat, 1 Jan 1970 +0130 00:00:00); System.out.println(date = + date); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) date =-540 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IllegalArgumentException at java.util.Date.parse(Date.java:404) at test2.main(test2.java:4) Suggested junit test case: DateTest.java - import junit.framework.*; import java.util.Date; public class DateTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(DateTest.class); } public void test_parse () { assertEquals(-540, Date.parse(Sat, 1 Jan 1970 +0130 00:00:00)); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-97) ZipOutputStream.close() throws IOException if the stream is already closed
ZipOutputStream.close() throws IOException if the stream is already closed -- Key: HARMONY-97 URL: http://issues.apache.org/jira/browse/HARMONY-97 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to 1.5 specification for сlose() method in interface Closeable: Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. Harmony throws IOException if the stream is already closed. Code to reproduce: import java.io.*; import java.util.zip.*; public class test2 { public static void main(String args[]) { ZipOutputStream zos = null; try { File f=new File(myFile); f.createNewFile(); f.deleteOnExit(); FileOutputStream ff=new FileOutputStream(f); BufferedOutputStream b=new BufferedOutputStream(ff); zos=new ZipOutputStream(new BufferedOutputStream(b)); zos.putNextEntry(new ZipEntry(myFile)); } catch (IOException ee) { ee.printStackTrace(); } try { zos.close(); zos.close(); System.out.println(PASSED); } catch (IOException ee) { System.out.println(FAILED); ee.printStackTrace(); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. FAILED java.io.IOException: Stream is closed at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:157) at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:66) at test2.main(test2.java:26) Suggested fix: Index: trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java === --- trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (revision 378195) +++ trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (working copy) @@ -77,8 +77,7 @@ */ public void close() throws IOException { finish(); - out.close(); - out = null; + out.close(); } /** @@ -165,9 +164,7 @@ * @exception IOException *If an error occurs while finishing */ - public void finish() throws IOException { - if (out == null) - throw new IOException(Msg.getString(K0059)); + public void finish() throws IOException { if (cDir == null) return; if (entries.size() == 0) Suggested junit test case: ZipOutputStreamTest.java - import junit.framework.*; import java.util.zip.*; import java.io.*; public class ZipOutputStreamTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(ZipOutputStream.class); } public void test_close() { ZipOutputStream zos = null; try { File f=new File(myFile); f.createNewFile(); f.deleteOnExit(); FileOutputStream ff=new FileOutputStream(f); BufferedOutputStream b=new BufferedOutputStream(ff); zos=new ZipOutputStream(new BufferedOutputStream(b)); zos.putNextEntry(new ZipEntry(myFile)); } catch (IOException ee) { fail(Unnexpected IOException); } try { zos.close(); zos.close(); } catch (IOException ee) { fail(Unnexpected IOException); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (HARMONY-98) java.util.BitSet.clear(int toIndex,int fromIndex) throws unexpected IndexOutOfBoundsException when toIndex=fromIndex
[ http://issues.apache.org/jira/browse/HARMONY-98?page=all ] Svetlana Samoilenko updated HARMONY-98: --- Attachment: fix.txt java.util.BitSet.clear(int toIndex,int fromIndex) throws unexpected IndexOutOfBoundsException when toIndex=fromIndex Key: HARMONY-98 URL: http://issues.apache.org/jira/browse/HARMONY-98 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Attachments: fix.txt According to 1.4.2 and 1.5 specification java.util.BitSet.clear(int,int) throws IndexOutOfBoundsException - if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. Harmony throws IndexOutOfBoundsException if toIndex=fromIndex. Code to reproduce: import java.util.BitSet; public class test2 { public static void main(String[] args) { BitSet set = new BitSet(); for(int i=0; i 20; i++) { set.set(i); } set.clear(10,10); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IndexOutOfBoundsException: Negative index specified at java.util.BitSet.clear(BitSet.java:423) at test2.main(test2.java:16) Suggested fix in attachment. Suggested junit test case: BitSetTest.java - import junit.framework.*; import java.util.BitSet; public class BitSetTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(BitSetTest.class); } public void test_clear() { BitSet set = new BitSet(); for(int i=0; i 20; i++) { set.set(i); } set.clear(10,10); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-97) ZipOutputStream.close() throws IOException if the stream is already closed
[ http://issues.apache.org/jira/browse/HARMONY-97?page=comments#action_12366743 ] Svetlana Samoilenko commented on HARMONY-97: Tim, thank you, bug is not reproducible with latest sources. ZipOutputStream.close() throws IOException if the stream is already closed -- Key: HARMONY-97 URL: http://issues.apache.org/jira/browse/HARMONY-97 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to 1.5 specification for ?lose() method in interface Closeable: Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. Harmony throws IOException if the stream is already closed. Code to reproduce: import java.io.*; import java.util.zip.*; public class test2 { public static void main(String args[]) { ZipOutputStream zos = null; try { File f=new File(myFile); f.createNewFile(); f.deleteOnExit(); FileOutputStream ff=new FileOutputStream(f); BufferedOutputStream b=new BufferedOutputStream(ff); zos=new ZipOutputStream(new BufferedOutputStream(b)); zos.putNextEntry(new ZipEntry(myFile)); } catch (IOException ee) { ee.printStackTrace(); } try { zos.close(); zos.close(); System.out.println(PASSED); } catch (IOException ee) { System.out.println(FAILED); ee.printStackTrace(); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. FAILED java.io.IOException: Stream is closed at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:157) at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:66) at test2.main(test2.java:26) Suggested fix: Index: trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java === --- trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (revision 378195) +++ trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (working copy) @@ -77,8 +77,7 @@ */ public void close() throws IOException { finish(); - out.close(); - out = null; + out.close(); } /** @@ -165,9 +164,7 @@ * @exception IOException *If an error occurs while finishing */ - public void finish() throws IOException { - if (out == null) - throw new IOException(Msg.getString(K0059)); + public void finish() throws IOException { if (cDir == null) return; if (entries.size() == 0) Suggested junit test case: ZipOutputStreamTest.java - import junit.framework.*; import java.util.zip.*; import java.io.*; public class ZipOutputStreamTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(ZipOutputStream.class); } public void test_close() { ZipOutputStream zos = null; try { File f=new File(myFile); f.createNewFile(); f.deleteOnExit(); FileOutputStream ff=new FileOutputStream(f); BufferedOutputStream b=new BufferedOutputStream(ff); zos=new ZipOutputStream(new BufferedOutputStream(b)); zos.putNextEntry(new ZipEntry(myFile)); } catch (IOException ee) { fail(Unnexpected IOException); } try { zos.close(); zos.close(); } catch
[jira] Commented: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
[ http://issues.apache.org/jira/browse/HARMONY-79?page=comments#action_12366745 ] Svetlana Samoilenko commented on HARMONY-79: Tim, thank you, I can't reproduce the bug with latest sources. java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException Key: HARMONY-79 URL: http://issues.apache.org/jira/browse/HARMONY-79 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison Attachments: AttributesTest.java, Attributes_patch.txt According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String. Harmony doesn't throw ClassCastException 1) if the name is not a Attributes.Name 2) if the value is not a String Code to reproduce: import java.util.jar.Attributes; public class test2 { public static void main(String[] args) { Attributes att=new Attributes(); try { att.put(new Object(), new String() ); } catch ( ClassCastException e) { System.out.println(ClassCastException if the name is not a Attributes.Name ); }; try { att.put(new Attributes.Name(IMPLEMENTATION_VENDOR), new Object()); } catch ( ClassCastException e) { System.out.println(ClassCastException if the value is not a String); return; }; System.out.println(Wrong. Must be ClassCastException); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ClassCastException if the name is not a Attributes.Name ClassCastException if the value is not a String C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. Wrong. Must be ClassCastException Siggested fix: to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 232 return map.put((Name) key, (String) value); Suggested junit test case: AttributesTest.java - import java.util.jar.*; import junit.framework.*; public class AttributesTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AttributesTest.class); } public void test_put () { Attributes att=new Attributes(); // ClassCastException if the name is not a Attributes.Name try { att.put(new Object(), new String() ); } catch ( ClassCastException e) { // expected }; //ClassCastException if the value is not a String try { att.put(new Attributes.Name(IMPLEMENTATION_VENDOR), new Object()); } catch ( ClassCastException e) { // expected }; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (HARMONY-98) java.util.BitSet.clear(int toIndex,int fromIndex) throws unexpected IndexOutOfBoundsException when toIndex=fromIndex
[ http://issues.apache.org/jira/browse/HARMONY-98?page=all ] Svetlana Samoilenko updated HARMONY-98: --- Attachment: fix_hrm-98.txt Tim, thank you for pointing my tipo out. Could you change fix.txt with fix_hrm-98.txt? java.util.BitSet.clear(int toIndex,int fromIndex) throws unexpected IndexOutOfBoundsException when toIndex=fromIndex Key: HARMONY-98 URL: http://issues.apache.org/jira/browse/HARMONY-98 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Attachments: fix.txt, fix_hrm-98.txt According to 1.4.2 and 1.5 specification java.util.BitSet.clear(int,int) throws IndexOutOfBoundsException - if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. Harmony throws IndexOutOfBoundsException if toIndex=fromIndex. Code to reproduce: import java.util.BitSet; public class test2 { public static void main(String[] args) { BitSet set = new BitSet(); for(int i=0; i 20; i++) { set.set(i); } set.clear(10,10); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IndexOutOfBoundsException: Negative index specified at java.util.BitSet.clear(BitSet.java:423) at test2.main(test2.java:16) Suggested fix in attachment. Suggested junit test case: BitSetTest.java - import junit.framework.*; import java.util.BitSet; public class BitSetTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(BitSetTest.class); } public void test_clear() { BitSet set = new BitSet(); for(int i=0; i 20; i++) { set.set(i); } set.clear(10,10); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-99) java.nio.charset.CharsetDecoder.decode(ByteBuffer in) does not throw MalformedInputException when buffer's current position is not legal
java.nio.charset.CharsetDecoder.decode(ByteBuffer in) does not throw MalformedInputException when buffer's current position is not legal Key: HARMONY-99 URL: http://issues.apache.org/jira/browse/HARMONY-99 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to 1.4.2 and 1.5 java.nio.charset.CharsetDecoder.decode(ByteBuffer in) throws MalformedInputException - If the byte sequence starting at the input buffer's current position is not legal for this charset and the current malformed-input action is CodingErrorAction.REPORT. Harmony does not throw MalformedInputException in this case as test listed below shows. Code to reproduce: import java.nio.*; import java.nio.charset.*; public class test2 { public static void main(String[] args) throws Exception { Charset cs =Charset.forName(utf-16); CharsetDecoder decoder = cs.newDecoder(); decoder.onMalformedInput(CodingErrorAction.REPORT); decoder.onUnmappableCharacter(CodingErrorAction.REPORT); CharBuffer out = CharBuffer.allocate(10); ByteBuffer in = ByteBuffer.wrap(new byte[] { 109, 97, 109}); CharBuffer res1 = decoder.decode(in); //output System.out.println(CharBuffer==+res1); System.out.println(CharBuffer.position ==+res1.position()); System.out.println(toHexString==+Integer.toHexString(res1.charAt(0))); System.out.println(ByteBuffer.position()==+in.position()); System.out.println(ByteBuffer.remaining()==+in.remaining()); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) java.nio.charset.MalformedInputException: Input length = 1 at java.nio.charset.CoderResult.throwException()V(CoderResult.java:260) at java.nio.charset.CharsetDecoder.decode(Ljava.nio.ByteBuffer;)Ljava.nio.CharBuffer;(CharsetDecoder.java:763) at test2.main([Ljava.lang.String;)V(test2.java:34) C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. res1== res1==0 toHexString==6d61 ByteBuffer.position()==3 ByteBuffer.remaining()==0 Suggested junit test case: CharsetDecoderTest.java - import junit.framework.*; import java.nio.*; import java.nio.charset.*; public class CharsetDecoderTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CharsetDecoderTest.class); } public void test_decode() { try { Charset cs =Charset.forName(utf-16); CharsetDecoder decoder = cs.newDecoder(); decoder.onMalformedInput(CodingErrorAction.REPORT); decoder.onUnmappableCharacter(CodingErrorAction.REPORT); CharBuffer out = CharBuffer.allocate(10); ByteBuffer in = ByteBuffer.wrap(new byte[] { 109, 97, 109}); CharBuffer res1 = decoder.decode(in); fail(MalformedInputException should have thrown); } catch (MalformedInputException e) { //expected } catch (CharacterCodingException e) { fail(unexpected CharacterCodingException); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-93) some methods in java.util.Collections don't throw NPE when the parameter is null
some methods in java.util.Collections don't throw NPE when the parameter is null - Key: HARMONY-93 URL: http://issues.apache.org/jira/browse/HARMONY-93 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 and 1.5 specification for the Collections class The methods of this class all throw a NullPointerException if the collections provided to them are null. Harmony does not throw NPE for some methods. Code to reproduce: import java.util.*; public class test2 { public static void main(String [] args) { SortedMap m = null; Map map=null; Set set=null; SortedSet sortedset=null; SortedMap sortedmap =null; Collection col=null; try { Collections.synchronizedCollection(col); System.out.println(synchronizedCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedMap(sortedmap); System.out.println(synchronizedSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedMap(map); System.out.println(synchronizedMap(map) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSet(set); System.out.println(synchronizedSet(set) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedSet(sortedset); System.out.println(synchronizedSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableCollection(col); System.out.println(unmodifiableCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableMap(map); System.out.println(unmodifiableMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSet(set); System.out.println(unmodifiableSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedMap(sortedmap); System.out.println(unmodifiableSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedSet(sortedset); System.out.println(unmodifiableSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. synchronizedCollection(null) must throw NPE synchronizedSortedMap(null) must throw NPE synchronizedMap(map) must throw NPE synchronizedSet(set) must throw NPE synchronizedSortedSet(null) must throw NPE unmodifiableCollection(null) must throw NPE unmodifiableMap(null) must throw NPE unmodifiableSet(null) must throw NPE unmodifiableSortedMap(null) must throw NPE unmodifiableSortedSet(null) must throw NPE Suggected fix and test in attachment. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (HARMONY-93) some methods in java.util.Collections don't throw NPE when the parameter is null
[ http://issues.apache.org/jira/browse/HARMONY-93?page=all ] Svetlana Samoilenko updated HARMONY-93: --- Attachment: CollectionsTest.java some methods in java.util.Collections don't throw NPE when the parameter is null - Key: HARMONY-93 URL: http://issues.apache.org/jira/browse/HARMONY-93 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Attachments: CollectionsTest.java According to j2se 1.4.2 and 1.5 specification for the Collections class The methods of this class all throw a NullPointerException if the collections provided to them are null. Harmony does not throw NPE for some methods. Code to reproduce: import java.util.*; public class test2 { public static void main(String [] args) { SortedMap m = null; Map map=null; Set set=null; SortedSet sortedset=null; SortedMap sortedmap =null; Collection col=null; try { Collections.synchronizedCollection(col); System.out.println(synchronizedCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedMap(sortedmap); System.out.println(synchronizedSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedMap(map); System.out.println(synchronizedMap(map) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSet(set); System.out.println(synchronizedSet(set) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedSet(sortedset); System.out.println(synchronizedSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableCollection(col); System.out.println(unmodifiableCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableMap(map); System.out.println(unmodifiableMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSet(set); System.out.println(unmodifiableSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedMap(sortedmap); System.out.println(unmodifiableSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedSet(sortedset); System.out.println(unmodifiableSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. synchronizedCollection(null) must throw NPE synchronizedSortedMap(null) must throw NPE synchronizedMap(map) must throw NPE synchronizedSet(set) must throw NPE synchronizedSortedSet(null) must throw NPE unmodifiableCollection(null) must throw NPE unmodifiableMap(null) must throw NPE unmodifiableSet(null) must throw NPE unmodifiableSortedMap(null) must throw NPE unmodifiableSortedSet(null) must throw NPE Suggected fix and test in attachment. -- This message is
[jira] Updated: (HARMONY-93) some methods in java.util.Collections don't throw NPE when the parameter is null
[ http://issues.apache.org/jira/browse/HARMONY-93?page=all ] Svetlana Samoilenko updated HARMONY-93: --- Attachment: fix.txt some methods in java.util.Collections don't throw NPE when the parameter is null - Key: HARMONY-93 URL: http://issues.apache.org/jira/browse/HARMONY-93 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Attachments: CollectionsTest.java, fix.txt According to j2se 1.4.2 and 1.5 specification for the Collections class The methods of this class all throw a NullPointerException if the collections provided to them are null. Harmony does not throw NPE for some methods. Code to reproduce: import java.util.*; public class test2 { public static void main(String [] args) { SortedMap m = null; Map map=null; Set set=null; SortedSet sortedset=null; SortedMap sortedmap =null; Collection col=null; try { Collections.synchronizedCollection(col); System.out.println(synchronizedCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedMap(sortedmap); System.out.println(synchronizedSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedMap(map); System.out.println(synchronizedMap(map) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSet(set); System.out.println(synchronizedSet(set) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.synchronizedSortedSet(sortedset); System.out.println(synchronizedSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableCollection(col); System.out.println(unmodifiableCollection(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableMap(map); System.out.println(unmodifiableMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSet(set); System.out.println(unmodifiableSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedMap(sortedmap); System.out.println(unmodifiableSortedMap(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } try { Collections.unmodifiableSortedSet(sortedset); System.out.println(unmodifiableSortedSet(null) must throw NPE); } catch (NullPointerException e) { System.out.println(PASSED); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. synchronizedCollection(null) must throw NPE synchronizedSortedMap(null) must throw NPE synchronizedMap(map) must throw NPE synchronizedSet(set) must throw NPE synchronizedSortedSet(null) must throw NPE unmodifiableCollection(null) must throw NPE unmodifiableMap(null) must throw NPE unmodifiableSet(null) must throw NPE unmodifiableSortedMap(null) must throw NPE unmodifiableSortedSet(null) must throw NPE Suggected fix and test in attachment. -- This message is
[jira] Commented: (HARMONY-86) java.util.zip.Inflater.needsDictionary() throws unspecified IllegalStateException
[ http://issues.apache.org/jira/browse/HARMONY-86?page=comments#action_12366443 ] Svetlana Samoilenko commented on HARMONY-86: Tim, thank you, bug is not reproducible with latest sources. java.util.zip.Inflater.needsDictionary() throws unspecified IllegalStateException - Key: HARMONY-86 URL: http://issues.apache.org/jira/browse/HARMONY-86 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to the j2se 1.4 and 1.5 specification java.util.zip.needsDictionary() method must not throw any exception. Harmony throws unspecified IllegalStateException that contradicts specification. Code to reproduce: import java.util.zip.*; public class test2 { public static void main(String args[]) { Inflater inf = new Inflater(); System.out.println(Inflater.needsDictionary() = +inf.needsDictionary()); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Inflater.needsDictionary() = true C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IllegalStateException at java.util.zip.Inflater.needsDictionary(Inflater.java:212) at test2.main(test2.java:8) Siggested fix: to remove the lines in needsDictionary() method in archive/src/main/java/java/util/zip/Inflater.java : 211 if (inputBuffer == null) 212throw new IllegalStateException(); Suggested junit test case: InflaterTest.java - import java.util.zip.*; import junit.framework.*; public class InflaterTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InflaterTest .class); } public void test_needsDictionary () { Inflater inf = new Inflater(); assertFalse(inf.needsDictionary()); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-85) java.util.jar.Attributes.Name(String name) does not throw IllegalArgumentException if name.length 70
[ http://issues.apache.org/jira/browse/HARMONY-85?page=comments#action_12366444 ] Svetlana Samoilenko commented on HARMONY-85: Tim, thank you, bug is not reproducible with latest sources. java.util.jar.Attributes.Name(String name) does not throw IllegalArgumentException if name.length 70 -- Key: HARMONY-85 URL: http://issues.apache.org/jira/browse/HARMONY-85 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 and 1.5 specification for Attributes.Name(String name) a string length cannot exceed 70 characters. Harmony does not throw IllegalArgumentException if name.length 70. Code to reproduce: import java.util.jar.*; public class test2 { public static void main(String args[]) throws Exception { try { //no more than 70 chars in attribute name allowed new Attributes.Name( 01234567890123456789012345678901234567890123456789012345678901234567890); System.out.println(Failed. Should be IllegalArgumentException ); } catch(IllegalArgumentException e) { System.out.println(Expected IllegalArgumentException); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Expected IllegalArgumentException C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. Failed. Should be IllegalArgumentException Siggested fix: @@ -84,7 +84,7 @@ public Name(String s) { int i = s.length(); - if (i == 0) + if (i == 0 || i 70) throw new IllegalArgumentException(); for (; --i = 0;) { char ch = s.charAt(i); Suggested junit test case: AttributesTest.java - import java.util.jar.*; import junit.framework.*; public class AttributesTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AttributesTest.class); } public void test_constructor () { try { new Attributes.Name( 01234567890123456789012345678901234567890123456789012345678901234567890); fail(Should be IllegalArgumentException); } catch(IllegalArgumentException e) { //expected } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.
[ http://issues.apache.org/jira/browse/HARMONY-67?page=comments#action_12366450 ] Svetlana Samoilenko commented on HARMONY-67: Tim, I confirm that there is no exeption any more, but the result of decode method is wrong. Harnony returns charbuf.length())==1 while BEA returns charbuf.length())==0. If to set UTF-8 charset, the result is equal. java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets. --- Key: HARMONY-67 URL: http://issues.apache.org/jira/browse/HARMONY-67 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 specification for Charset.decode(ByteBuffer b) the method must not throw any exceptions. The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following: UTF-16BE, UTF-16LE, UTF-16. BEA does not throw any exceptions. Code to reproduce: import java.nio.charset.Charset; import java.nio.ByteBuffer; import java.nio.CharBuffer; public class test2 { public static void main(String[] args) throws Exception { byte[] b = new byte[] {(byte)1}; ByteBuffer buf= ByteBuffer.wrap(b); CharBuffer charbuf=Charset.forName(UTF-16).decode(buf); System.out.println(CharBuffer.length()=+ charbuf.length()); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) CharBuffer.length()=0 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.nio.BufferOverflowException at java.nio.CharBuffer.put(CharBuffer.java:662) at java.nio.CharBuffer.put(CharBuffer.java:629) at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) at java.nio.charset.Charset.decode(Charset.java:630) at test2.main(test2.java:8) Suggested junit test case: CharsetTest.java - import java.nio.charset.Charset; import java.nio.ByteBuffer; import java.nio.CharBuffer; import junit.framework.*; public class CharsetTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CharsetTest.class); } public void test_decode() { byte[] b = new byte[] {(byte)1}; ByteBuffer buf= ByteBuffer.wrap(b); CharBuffer charbuf=Charset.forName(UTF-16).decode(buf); assertEquals(Assert 0: charset UTF-16,0,charbuf.length()); charbuf=Charset.forName(UTF-16BE).decode(buf); assertEquals(Assert 1: charset UTF-16BE,0, charbuf.length()); charbuf=Charset.forName(UTF-16LE).decode(buf); assertEquals(Assert 2: charset UTF16LE,0, charbuf.length()); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-94) java.util.Collections.binarySearch(List, Object, Comparator c) throws NPE when c is null
java.util.Collections.binarySearch(List, Object, Comparator c) throws NPE when c is null Key: HARMONY-94 URL: http://issues.apache.org/jira/browse/HARMONY-94 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 and 1.5 specification for java.util.Collections.binarySearch(List, Object, Comparator c) method null value of Comparator c indicates, that the elements' natural ordering should be used. Harmony throws NPE in this case that contradicts specification. Code to reproduce: import java.util.*; public class test2 { public static void main(String args[]){ LinkedList lst = new LinkedList(); lst.add(new Integer(30)); Collections.sort(lst, null); int i = Collections.binarySearch(lst, new Integer(2), null); System.out.println(Index of search key = + i); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Index of search key =-1 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.NullPointerException at java.util.Collections.binarySearch(Collections.java:1347) at test2.main(test2.java:8) Suggected fix: Index: trunk/modules/luni/src/main/java/java/util/Collections.java === --- trunk/modules/luni/src/main/java/java/util/Collections.java (revision 377385) +++ trunk/modules/luni/src/main/java/java/util/Collections.java (working copy) @@ -1340,6 +1340,9 @@ */ public static int binarySearch(List list, Object object, Comparator comparator) { +if ( comparator== null) { +return Collections.binarySearch(list, object); +} if (!(list instanceof RandomAccess)) { ListIterator it = list.listIterator(); while (it.hasNext()) { Suggested junit test case: CollectionsTest.java - import junit.framework.*; import java.util.*; public class CollectionsTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CollectionsTest.class); } public void test_binarySearch () { LinkedList lst = new LinkedList(); lst.add(new Integer(30)); Collections.sort(lst, null); assertEquals(-1, Collections.binarySearch(lst, new Integer(2), null)); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-89) java.util.jar.Manifest().read(InputStream is) throws OutOfMemoryError
java.util.jar.Manifest().read(InputStream is) throws OutOfMemoryError - Key: HARMONY-89 URL: http://issues.apache.org/jira/browse/HARMONY-89 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Synopsis: java.util.jar.Manifest().read(InputStream is) throws OutOfMemoryError Description: For test listed below BEA throws IOException while Harmony throws OutOfMemoryError. The test creates an instance of InputStreamImpl where read method is implemented in simple way and returned any integer value, in particular in.available()== 0 and in.read(buf) == buf.length. There is no checking for this conditions in the InitManifest.readLines method and as a result an endless loop occurs. Suggested fix in attachment may be incomplete, needs additional investigation. Code to reproduce: import java.util.jar.*; import java.io.*; public class test2 { public static void main(String args[]) { InputStream is = new InputStreamImpl(); try { new Manifest().read(is); } catch (IOException e) { e.printStackTrace(); System.out.println(PASSED); } } } class InputStreamImpl extends InputStream{ public InputStreamImpl() { super(); } public int read() { return 0; } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) java.io.IOException: line too long at java.util.jar.Attributes.read(Ljava.util.jar.Manifest$FastInputStream;[B)V(Attributes.java:356) at java.util.jar.Manifest.read(Ljava.io.InputStream;)V(Manifest.java:167) at test2.main([Ljava.lang.String;)V(test2.java:8) PASSED C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.OutOfMemoryError at java.util.jar.InitManifest.readLines(InitManifest.java:224) at java.util.jar.InitManifest.init(InitManifest.java:61) at java.util.jar.Manifest.read(Manifest.java:273) at test2.main(test2.java:10) Suggested junit test case: ManifestTest.java - import junit.framework.*; import java.io.*; import java.util.jar.Manifest; public class ManifestTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(ManifestTest.class); } public void test_read () { InputStream is = new InputStreamImpl(); try { new Manifest().read(is); } catch (IOException e) { //expected } } } class InputStreamImpl extends InputStream public InputStreamImpl() { super(); } public int read() { return 0; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-82) wrong signature for 2 constructors in java.net.DatagramPacket
[ http://issues.apache.org/jira/browse/HARMONY-82?page=comments#action_12365845 ] Svetlana Samoilenko commented on HARMONY-82: Verified on revision 376009. Two constrictors have correct sinhature. Thanks. wrong signature for 2 constructors in java.net.DatagramPacket - Key: HARMONY-82 URL: http://issues.apache.org/jira/browse/HARMONY-82 Project: Harmony Type: Bug Reporter: Svetlana Samoilenko Assignee: Tim Ellison Priority: Minor According to j2se 1.4.2 and 1.5 specification java.net.DatagramPacket.(byte[], int, int, java.net.SocketAddress) and java.net.DatagramPacket.(byte[], int, java.net.SocketAddress) must throw SocketException. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-72) java.net.URLConnection.setAllowUserInteraction (boolean b) throws unspecified SecurityException
[ http://issues.apache.org/jira/browse/HARMONY-72?page=comments#action_12365848 ] Svetlana Samoilenko commented on HARMONY-72: Verified on revision 376014. Expected IllegalStateException exception is thrown. Thanks. java.net.URLConnection.setAllowUserInteraction (boolean b) throws unspecified SecurityException --- Key: HARMONY-72 URL: http://issues.apache.org/jira/browse/HARMONY-72 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 spec java.net.URLConnection.setAllowUserInteraction(boolean) throws IllegalStateException - if already connected. Harmony throws java.lang.SecurityException instead. Code to reproduce: import java.io.IOException; import java.net.*; public class test2 { public static void main(String[] args) { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { System.out.println(unexpected MalformedURLException+e); } catch (IOException f) { System.out.println(unexpected IOException+f); } try { u.setAllowUserInteraction(false); } catch (IllegalStateException e) { System.out.println(OK. Expected IllegalStateException); e.printStackTrace(); }; } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) OK. Expected IllegalStateException java.lang.IllegalStateException: Already connected at java.net.URLConnection.setAllowUserInteraction(Z)V(URLConnection.java:765) at test2.main([Ljava.lang.String;)V(test2.java:16) at test2.main([Ljava.lang.String;)V(test2.java:18) C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.SecurityException: Connection already established at java.net.URLConnection.setAllowUserInteraction(URLConnection.java:736) at test2.main(test2.java:18) Suggested junit test case: URLConnectionTest.java - import java.io.IOException; import java.net.*; import junit.framework.*; public class URLConnectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLConnectionTest.class); } public void test_setUseCaches () { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { fail(unexpected MalformedURLException+e); } catch (IOException f) { fail(unexpected IOException+f); } try { u.setAllowUserInteraction(false); } catch (IllegalStateException e) { //expected }; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-71) java.net.URLConnection.setUseCaches throws unspecified IllegalAccessError
[ http://issues.apache.org/jira/browse/HARMONY-71?page=comments#action_12365851 ] Svetlana Samoilenko commented on HARMONY-71: Verified on revision 376014. Expected IllegalStateException exception is thrown. Thanks. java.net.URLConnection.setUseCaches throws unspecified IllegalAccessError -- Key: HARMONY-71 URL: http://issues.apache.org/jira/browse/HARMONY-71 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 specification method java.net.URLConnection.setUseCaches(boolean) throws IllegalStateException, if already connected. Harmony throws java.lang.IllegalAccessError instead, that contradicts the specification. Code to reproduce: import java.io.IOException; import java.net.*; public class test2 { public static void main(String[] args) { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { System.out.println(unexpected MalformedURLException+e); } catch (IOException f) { System.out.println(unexpected IOException+f); } try { u.setUseCaches(true); } catch (IllegalStateException e) { System.out.println(OK. Expected IllegalStateException); e.printStackTrace(); }; } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) OK. Expected IllegalStateException java.lang.IllegalStateException: Already connected at java.net.URLConnection.setUseCaches(Z)V(URLConnection.java:828) at test2.main([Ljava.lang.String;)V(test2.java:17) C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IllegalAccessError: Connection already established at java.net.URLConnection.setUseCaches(URLConnection.java:923) at test2.main(test2.java:17) Suggested junit test case: URLConnectionTest.java - import java.io.IOException; import java.net.*; import junit.framework.*; public class URLConnectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLConnectionTest.class); } public void test_setUseCaches () { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { fail(unexpected MalformedURLException+e); } catch (IOException f) { fail(unexpected IOException+f); } try { u.setUseCaches(true); } catch (IllegalStateException e) { //expected }; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-85) java.util.jar.Attributes.Name(String name) does not throw IllegalArgumentException if name.length 70
java.util.jar.Attributes.Name(String name) does not throw IllegalArgumentException if name.length 70 -- Key: HARMONY-85 URL: http://issues.apache.org/jira/browse/HARMONY-85 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 and 1.5 specification for Attributes.Name(String name) a string length cannot exceed 70 characters. Harmony does not throw IllegalArgumentException if name.length 70. Code to reproduce: import java.util.jar.*; public class test2 { public static void main(String args[]) throws Exception { try { //no more than 70 chars in attribute name allowed new Attributes.Name( 01234567890123456789012345678901234567890123456789012345678901234567890); System.out.println(Failed. Should be IllegalArgumentException ); } catch(IllegalArgumentException e) { System.out.println(Expected IllegalArgumentException); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Expected IllegalArgumentException C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. Failed. Should be IllegalArgumentException Siggested fix: @@ -84,7 +84,7 @@ public Name(String s) { int i = s.length(); - if (i == 0) + if (i == 0 || i 70) throw new IllegalArgumentException(); for (; --i = 0;) { char ch = s.charAt(i); Suggested junit test case: AttributesTest.java - import java.util.jar.*; import junit.framework.*; public class AttributesTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AttributesTest.class); } public void test_constructor () { try { new Attributes.Name( 01234567890123456789012345678901234567890123456789012345678901234567890); fail(Should be IllegalArgumentException); } catch(IllegalArgumentException e) { //expected } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-86) java.util.zip.Inflater.needsDictionary() throws unspecified IllegalStateException
java.util.zip.Inflater.needsDictionary() throws unspecified IllegalStateException - Key: HARMONY-86 URL: http://issues.apache.org/jira/browse/HARMONY-86 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to the j2se 1.4 and 1.5 specification java.util.zip.needsDictionary() method must not throw any exception. Harmony throws unspecified IllegalStateException that contradicts specification. Code to reproduce: import java.util.zip.*; public class test2 { public static void main(String args[]) { Inflater inf = new Inflater(); System.out.println(Inflater.needsDictionary() = +inf.needsDictionary()); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Inflater.needsDictionary() = true C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IllegalStateException at java.util.zip.Inflater.needsDictionary(Inflater.java:212) at test2.main(test2.java:8) Siggested fix: to remove the lines in needsDictionary() method in archive/src/main/java/java/util/zip/Inflater.java : 211 if (inputBuffer == null) 212throw new IllegalStateException(); Suggested junit test case: InflaterTest.java - import java.util.zip.*; import junit.framework.*; public class InflaterTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InflaterTest .class); } public void test_needsDictionary () { Inflater inf = new Inflater(); assertFalse(inf.needsDictionary()); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-83) java.net.URL(String, String, int port, String) throws MalformedURLException when port is 65535
[ http://issues.apache.org/jira/browse/HARMONY-83?page=comments#action_12365854 ] Svetlana Samoilenko commented on HARMONY-83: Tim , thank you, I agree with your fix. Verified on revision 376452. java.net.URL(String, String, int port, String) throws MalformedURLException when port is 65535 Key: HARMONY-83 URL: http://issues.apache.org/jira/browse/HARMONY-83 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison Priority: Minor According to the j2se 1.4 and 1.5 specification constructor java.net.URL(String, String, int port, String) throws MalformedURLException - if an unknown protocol is specified. Harmony throws the exception if protocol is correct but a port out of range that contradicts specification. Code to reproduce: import java.net.*; public class test2 { public static void main(String[] args) { try { new URL(http, google.com, 1093812784, file ); System.out.println(Test passed); } catch (MalformedURLException e) { e.printStackTrace(); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Test passed C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.net.MalformedURLException: Port out of range: 1093812784 at java.net.URL.init(URL.java:382) at java.net.URL.init(URL.java:356) at test2.main(test2.java:6) Suggested fix in attachment. Suggested junit test case: URLTest.java - import java.net.*; import junit.framework.*; public class URLTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLTest.class); } public void test_constructor () { try { new URL(http, google.com, 1093812784, file ); } catch (MalformedURLException e) { fail(unexpected MalformedURLException); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-82) wrong signature for 2 constructors in java.net.DatagramPacket
wrong signature for 2 constructors in java.net.DatagramPacket - Key: HARMONY-82 URL: http://issues.apache.org/jira/browse/HARMONY-82 Project: Harmony Type: Bug Reporter: Svetlana Samoilenko Priority: Minor According to j2se 1.4.2 and 1.5 specification java.net.DatagramPacket.(byte[], int, int, java.net.SocketAddress) and java.net.DatagramPacket.(byte[], int, java.net.SocketAddress) must throw SocketException. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-83) java.net.URL(String, String, int port, String) throws MalformedURLException when protocol is known
java.net.URL(String, String, int port, String) throws MalformedURLException when protocol is known -- Key: HARMONY-83 URL: http://issues.apache.org/jira/browse/HARMONY-83 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Priority: Minor According to the j2se 1.4 and 1.5 specification constructor java.net.URL(String, String, int port, String) throws MalformedURLException - if an unknown protocol is specified. Harmony throws the exception if protocol is correct but a port out of range that contradicts specification. Code to reproduce: import java.net.*; public class test2 { public static void main(String[] args) { try { new URL(http, google.com, 1093812784, file ); System.out.println(Test passed); } catch (MalformedURLException e) { e.printStackTrace(); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Test passed C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.net.MalformedURLException: Port out of range: 1093812784 at java.net.URL.init(URL.java:382) at java.net.URL.init(URL.java:356) at test2.main(test2.java:6) Suggested fix in attachment. Suggested junit test case: URLTest.java - import java.net.*; import junit.framework.*; public class URLTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLTest.class); } public void test_constructor () { try { new URL(http, google.com, 1093812784, file ); } catch (MalformedURLException e) { fail(unexpected MalformedURLException); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-83) java.net.URL(String, String, int port, String) throws MalformedURLException when protocol is known
[ http://issues.apache.org/jira/browse/HARMONY-83?page=comments#action_12365543 ] Svetlana Samoilenko commented on HARMONY-83: I could not attach a file. server reperted about error. Index: C:/users/TCKTeam/ws/trunk/modules/luni/src/main/java/java/net/URL.java === --- C:/users/TCKTeam/ws/trunk/modules/luni/src/main/java/java/net/URL.java (revision 375577) +++ C:/users/TCKTeam/ws/trunk/modules/luni/src/main/java/java/net/URL.java (working copy) @@ -313,9 +313,6 @@ throw new MalformedURLException(e.toString()); } - if (port -1 || port 65535) - throw new MalformedURLException(com.ibm.oti.util.Msg.getString( - K0325, port)); //$NON-NLS-1$ } /** @@ -378,10 +375,7 @@ */ public URL(String protocol, String host, int port, String file, URLStreamHandler handler) throws MalformedURLException { - if (port -1 || port 65535) - throw new MalformedURLException(com.ibm.oti.util.Msg.getString( - K0325, port)); //$NON-NLS-1$ - + if (host != null host.indexOf(:) != -1 host.charAt(0) != '[') { host = [ + host + ]; } java.net.URL(String, String, int port, String) throws MalformedURLException when protocol is known -- Key: HARMONY-83 URL: http://issues.apache.org/jira/browse/HARMONY-83 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Priority: Minor According to the j2se 1.4 and 1.5 specification constructor java.net.URL(String, String, int port, String) throws MalformedURLException - if an unknown protocol is specified. Harmony throws the exception if protocol is correct but a port out of range that contradicts specification. Code to reproduce: import java.net.*; public class test2 { public static void main(String[] args) { try { new URL(http, google.com, 1093812784, file ); System.out.println(Test passed); } catch (MalformedURLException e) { e.printStackTrace(); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Test passed C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.net.MalformedURLException: Port out of range: 1093812784 at java.net.URL.init(URL.java:382) at java.net.URL.init(URL.java:356) at test2.main(test2.java:6) Suggested fix in attachment. Suggested junit test case: URLTest.java - import java.net.*; import junit.framework.*; public class URLTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLTest.class); } public void test_constructor () { try { new URL(http, google.com, 1093812784, file ); } catch (MalformedURLException e) { fail(unexpected MalformedURLException); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException Key: HARMONY-79 URL: http://issues.apache.org/jira/browse/HARMONY-79 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String. Harmony doesn't throw ClassCastException 1) if the name is not a Attributes.Name 2) if the value is not a String Code to reproduce: import java.util.jar.Attributes; public class test2 { public static void main(String[] args) { Attributes att=new Attributes(); try { att.put(new Object(), new String() ); } catch ( ClassCastException e) { System.out.println(ClassCastException if the name is not a Attributes.Name ); }; try { att.put(new Attributes.Name(IMPLEMENTATION_VENDOR), new Object()); } catch ( ClassCastException e) { System.out.println(ClassCastException if the value is not a String); return; }; System.out.println(Wrong. Must be ClassCastException); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ClassCastException if the name is not a Attributes.Name ClassCastException if the value is not a String C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. Wrong. Must be ClassCastException Siggested fix: to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 232 return map.put((Name) key, (String) value); Suggested junit test case: AttributesTest.java - import java.util.jar.*; import junit.framework.*; public class AttributesTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AttributesTest.class); } public void test_put () { Attributes att=new Attributes(); // ClassCastException if the name is not a Attributes.Name try { att.put(new Object(), new String() ); } catch ( ClassCastException e) { // expected }; //ClassCastException if the value is not a String try { att.put(new Attributes.Name(IMPLEMENTATION_VENDOR), new Object()); } catch ( ClassCastException e) { // expected }; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-61) java.net.InetAddress.getByAddress(null) throws NPE insread of UnknownHostException
[ http://issues.apache.org/jira/browse/HARMONY-61?page=comments#action_12365422 ] Svetlana Samoilenko commented on HARMONY-61: Tim, I used revision 375338 and the problem resolved as expected. Output is: ***OK. Expected UnknownHostException. java.net.UnknownHostException: Invalid IP Address is neither 4 or 16 bytes Thanks a lot for quick response. java.net.InetAddress.getByAddress(null) throws NPE insread of UnknownHostException -- Key: HARMONY-61 URL: http://issues.apache.org/jira/browse/HARMONY-61 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 specification for java.net.InetAddress.getByAddress(byte[] addr) the method must throw UnknownHostException if IP address is of illegal length. IPv4 address byte array must be 4 bytes long and IPv6 byte array must be 16 bytes long. There is no mention about NPE at all. Mentions about NPE in case of null argument were not found in java.net package specification. The test listed below shows that getByAddress (null) throws NPE. BEA throws UnknownHostException. Code to reproduce: import java.net.*; public class test2 { public static void main (String[] args) { try { InetAddress.getByAddress (null); } catch (UnknownHostException e) { System.out.println(***OK. Expected UnknownHostException. + e); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***OK. UnknownHostException=:java.net.UnknownHostException: addr is of illegal length C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.NullPointerException at java.net.InetAddress.getByAddress(InetAddress.java:735) at java.net.InetAddress.getByAddress(InetAddress.java:713) at test2.main(test2.java:7) Suggested junit test case: InetAddressTest.java - import java.net.*; import junit.framework.*; public class InetAddressTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InetAddressTest.class); } public void test_getByAddress() { try { InetAddress.getByAddress (null); fail(Assert 0: UnknownHostException must be thrown); } catch (UnknownHostException e) { } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets
[ http://issues.apache.org/jira/browse/HARMONY-60?page=comments#action_12365424 ] Svetlana Samoilenko commented on HARMONY-60: Tim, I used revision 375380 and the IP6 address in [ ] now. Test output is: **OK, host is in square brackets=[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210] Actually, it is BEA bug, they assume that, for example, http://google.com/; is a IPV6 address, presumably because it contains ':'. it is just incorrect host address, but URL should not complain unlike URI. It would be better to check that it is real correct IP6 address, but may be we should copy all BEA bugs for compatibility ;) ? java.net.URL.getHost() must return the IPv6 address enclosed in square brackets --- Key: HARMONY-60 URL: http://issues.apache.org/jira/browse/HARMONY-60 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 specification for java.net.URL.getHost() the method must return the IPv6 address enclosed in square brackets ('[' and ']'). The test listed below shows an absence of square brackets for the IPv6 address. Code to reproduce: import java.net.*; public class test2 { public static void main(String[] args) { URL url=null; String protocol = http; int port = -1; String host = FEDC:BA98:7654:3210:FEDC:BA98:7654:3210; String file = myFile; try { url = new URL(protocol,host,port,file); } catch (Exception e) { System.out.println(URL.URL(protocol,host,port,file) caused: + e); return; } if (url.getHost().equals([+host+])) { System.out.println(OK, host is in square brackets=+url.getHost()); } else { System.out.println(Incorrect, host is not in square brackets=+url.getHost()); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***OK, host is in square brackets=[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210] C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. ***Incorrect, host is not in square brackets=FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 Suggested junit test case: URLTest.java - import java.net.*; import junit.framework.*; public class URLTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLTest.class); } public void test_getHost() { URL url=null; String protocol = http; int port = -1; String host = FEDC:BA98:7654:3210:FEDC:BA98:7654:3210; String file = myFile; try { url = new URL(protocol,host,port,file); } catch (Exception e) { fail(Assert 0: URL.URL(protocol,host,port,file) caused: + e); } assertEquals (([+host+]), url.getHost()); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-56) java.net.InetAddress.getAllByName(null) throws UnknownHostException instead of valid InetAddress
[ http://issues.apache.org/jira/browse/HARMONY-56?page=comments#action_12365427 ] Svetlana Samoilenko commented on HARMONY-56: Tim, I used revision 375576 and all works fine. Test output is: ***InetAddress.getAllByName(null)[0] returned localhost/127.0.0.1 Thank you. java.net.InetAddress.getAllByName(null) throws UnknownHostException instead of valid InetAddress Key: HARMONY-56 URL: http://issues.apache.org/jira/browse/HARMONY-56 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Assignee: Tim Ellison According to j2se 1.4.2 specification java.net.InetAddress.getAllByName(String host) method allows a host is null. In this case the InetAddress representing an address of the loopback interface is returned. But as we can see from the test listed below java.net.InetAddress.getAllByName(null) throws UnknownHostException instead of valid InetAddress. Code to reproduce: import java.net.*; public class test2 { public static void main (String[] args) { try { InetAddress[] ia = InetAddress.getAllByName(null); for (int i = 0; iia.length; i++) { System.out.println(***InetAddress.getAllByName(null)[+i+] returned + ia[i]); } } catch (Exception e) { System.out.println(***Unexpected exception: + e); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***InetAddress.getAllByName(null)[0] returned localhost/127.0.0.1 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. ***Unexpected exception:java.net.UnknownHostException: No host name provided Suggested junit test case: InetAddressTest.java - import java.net.*; import junit.framework.*; public class InetAddressTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InetAddressTest.class); } public void test_getAllByName() { try { InetAddress[] ia = InetAddress.getAllByName(null); assertEquals (Assert 0: getAllByName() returns incorrect value + ia[0].toString(),localhost/127.0.0.1,ia[0].toString()); } catch (Exception e) { fail(Assert 1: Unexpected exception: + e); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-71) java.net.URLConnection.setUseCaches throws unspecified IllegalAccessError
java.net.URLConnection.setUseCaches throws unspecified IllegalAccessError -- Key: HARMONY-71 URL: http://issues.apache.org/jira/browse/HARMONY-71 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 specification method java.net.URLConnection.setUseCaches(boolean) throws IllegalStateException, if already connected. Harmony throws java.lang.IllegalAccessError instead, that contradicts the specification. Code to reproduce: import java.io.IOException; import java.net.*; public class test2 { public static void main(String[] args) { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { System.out.println(unexpected MalformedURLException+e); } catch (IOException f) { System.out.println(unexpected IOException+f); } try { u.setUseCaches(true); } catch (IllegalStateException e) { System.out.println(OK. Expected IllegalStateException); e.printStackTrace(); }; } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) OK. Expected IllegalStateException java.lang.IllegalStateException: Already connected at java.net.URLConnection.setUseCaches(Z)V(URLConnection.java:828) at test2.main([Ljava.lang.String;)V(test2.java:17) C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.IllegalAccessError: Connection already established at java.net.URLConnection.setUseCaches(URLConnection.java:923) at test2.main(test2.java:17) Suggested junit test case: URLConnectionTest.java - import java.io.IOException; import java.net.*; import junit.framework.*; public class URLConnectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLConnectionTest.class); } public void test_setUseCaches () { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { fail(unexpected MalformedURLException+e); } catch (IOException f) { fail(unexpected IOException+f); } try { u.setUseCaches(true); } catch (IllegalStateException e) { //expected }; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-72) java.net.URLConnection.setAllowUserInteraction (boolean b) throws unspecified SecurityException
java.net.URLConnection.setAllowUserInteraction (boolean b) throws unspecified SecurityException --- Key: HARMONY-72 URL: http://issues.apache.org/jira/browse/HARMONY-72 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 spec java.net.URLConnection.setAllowUserInteraction(boolean) throws IllegalStateException - if already connected. Harmony throws java.lang.SecurityException instead. Code to reproduce: import java.io.IOException; import java.net.*; public class test2 { public static void main(String[] args) { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { System.out.println(unexpected MalformedURLException+e); } catch (IOException f) { System.out.println(unexpected IOException+f); } try { u.setAllowUserInteraction(false); } catch (IllegalStateException e) { System.out.println(OK. Expected IllegalStateException); e.printStackTrace(); }; } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) OK. Expected IllegalStateException java.lang.IllegalStateException: Already connected at java.net.URLConnection.setAllowUserInteraction(Z)V(URLConnection.java:765) at test2.main([Ljava.lang.String;)V(test2.java:16) at test2.main([Ljava.lang.String;)V(test2.java:18) C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.SecurityException: Connection already established at java.net.URLConnection.setAllowUserInteraction(URLConnection.java:736) at test2.main(test2.java:18) Suggested junit test case: URLConnectionTest.java - import java.io.IOException; import java.net.*; import junit.framework.*; public class URLConnectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLConnectionTest.class); } public void test_setUseCaches () { HttpURLConnection u=null; try { u=(HttpURLConnection)(new URL(http://intel.com;).openConnection()); u.connect(); } catch (MalformedURLException e) { fail(unexpected MalformedURLException+e); } catch (IOException f) { fail(unexpected IOException+f); } try { u.setAllowUserInteraction(false); } catch (IllegalStateException e) { //expected }; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-73) java.net.InetAddress.getLocalHost() returns wrong host name for loopback address
java.net.InetAddress.getLocalHost() returns wrong host name for loopback address - Key: HARMONY-73 URL: http://issues.apache.org/jira/browse/HARMONY-73 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko Priority: Minor J2se 1.4.2 and 5.0 specifications for java.net.InetAddress.getLocalHost() read, that if there is a security manager, its checkConnect method is called with the local host name and -1 as its arguments to see if the operation is allowed. If the operation is not allowed, an InetAddress representing the loopback address is returned as hostname/hostaddress (as followed from toString() specification). The test listed below shows that the returned loopback address has wrong hostname, 127.0.0.1 instead of loopback. Inet_SecurityManager class is called twice and therefore host name is substituted with hostaddress address. Code to reproduce: import java.net.*; public class test2 { public static void main(String[] args) { try { System.setSecurityManager(new Inet_SecurityManager()); System.out.println(Loopback address = + InetAddress.getLocalHost()); } catch (Exception e){ System.out.println(Unexpected exception = + e); }; } } class Inet_SecurityManager extends SecurityManager { public void checkConnect(String host, int port) { super.checkConnect(host,port); throw new SecurityException(); } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Inet_SecurityManager :host= nswssamoil1 Inet_SecurityManager :port= -1 Loopback address = localhost/127.0.0.1 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. Inet_SecurityManager :host= nswssamoil1 Inet_SecurityManager :port= -1 Inet_SecurityManager :host= localhost Inet_SecurityManager :port= -1 Loopback address = 127.0.0.1/127.0.0.1 Suggested junit test case: InetAddressTest.java - import java.net.*; import junit.framework.*; public class InetAddressTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InetAddress.class); } public void test_getLocalHost() { try{ System.setSecurityManager(new Inet_SecurityManager()); String hostname=InetAddress.getLocalHost().getHostName(); assertEquals(localhost, hostname); } catch (Exception e){ fail(Unexpected exception = + e); }; } } class Inet_SecurityManager extends SecurityManager { public void checkConnect(String host, int port) { super.checkConnect(host,port); throw new SecurityException(); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-68) java.nio.charset.Charset.isSupported(String charsetName) does not throw IllegalCharsetNameException for spoiled standard sharset name
java.nio.charset.Charset.isSupported(String charsetName) does not throw IllegalCharsetNameException for spoiled standard sharset name - Key: HARMONY-68 URL: http://issues.apache.org/jira/browse/HARMONY-68 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 specification for Charset.isSupported(String charsetName) the method must throw IllegalCharsetNameException if the given charset name is illegal . Legal charset name must begin with either a letter or a digit. The test listed below shows that there is no the exception if to insert - or _ symbols before standard sharset name, for example -UTF-8 or _US-ASCII. Moreover the method returns true in this case. BEA also does not throw the exception but returns false. Code to reproduce: import java.nio.charset.*; public class test2 { public static void main (String[] args) { // string starts neither a letter nor a digit boolean sup=false; try{ sup=Charset.isSupported(-UTF-8); System.out.println(***BAD. should be exception; sup=+sup); sup=Charset.isSupported(_US-ASCII); System.out.println(***BAD. should be exception; sup=+sup); } catch (IllegalCharsetNameException e) { System.out.println(***OK. Expected IllegalCharsetNameException + e); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***BAD. should be exception; sup=false ***BAD. should be exception; sup=false C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. ***BAD. should be exception; sup=true ***BAD. should be exception; sup=true Suggested junit test case: CharserTest.java - import java.nio.charset.*; import junit.framework.*; public class CharsetTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CharsetTest.class); } public void test_isSupported() { boolean sup=false; // string starts neither a letter nor a digit try{ sup=Charset.isSupported(-UTF-8); fail(***BAD. should be exception IllegalCharsetNameException); } catch (IllegalCharsetNameException e) { //expected } // string starts neither a letter nor a digit try{ sup=Charset.isSupported(_US-ASCII); fail(***BAD. should be exception IllegalCharsetNameException); } catch (IllegalCharsetNameException e) { //expected } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-56) java.net.InetAddress.getAllByName(null) throws UnknownHostException instead of valid InetAddress
java.net.InetAddress.getAllByName(null) throws UnknownHostException instead of valid InetAddress Key: HARMONY-56 URL: http://issues.apache.org/jira/browse/HARMONY-56 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 specification java.net.InetAddress.getAllByName(String host) method allows a host is null. In this case the InetAddress representing an address of the loopback interface is returned. But as we can see from the test listed below java.net.InetAddress.getAllByName(null) throws UnknownHostException instead of valid InetAddress. Code to reproduce: import java.net.*; public class test2 { public static void main (String[] args) { try { InetAddress[] ia = InetAddress.getAllByName(null); for (int i = 0; iia.length; i++) { System.out.println(***InetAddress.getAllByName(null)[+i+] returned + ia[i]); } } catch (Exception e) { System.out.println(***Unexpected exception: + e); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***InetAddress.getAllByName(null)[0] returned localhost/127.0.0.1 C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. ***Unexpected exception:java.net.UnknownHostException: No host name provided Suggested junit test case: InetAddressTest.java - import java.net.*; import junit.framework.*; public class InetAddressTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InetAddressTest.class); } public void test_getAllByName() { try { InetAddress[] ia = InetAddress.getAllByName(null); assertEquals (Assert 0: getAllByName() returns incorrect value + ia[0].toString(),localhost/127.0.0.1,ia[0].toString()); } catch (Exception e) { fail(Assert 1: Unexpected exception: + e); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets
java.net.URL.getHost() must return the IPv6 address enclosed in square brackets --- Key: HARMONY-60 URL: http://issues.apache.org/jira/browse/HARMONY-60 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 specification for java.net.URL.getHost() the method must return the IPv6 address enclosed in square brackets ('[' and ']'). The test listed below shows an absence of square brackets for the IPv6 address. Code to reproduce: import java.net.*; public class test2 { public static void main(String[] args) { URL url=null; String protocol = http; int port = -1; String host = FEDC:BA98:7654:3210:FEDC:BA98:7654:3210; String file = myFile; try { url = new URL(protocol,host,port,file); } catch (Exception e) { System.out.println(URL.URL(protocol,host,port,file) caused: + e); return; } if (url.getHost().equals([+host+])) { System.out.println(OK, host is in square brackets=+url.getHost()); } else { System.out.println(Incorrect, host is not in square brackets=+url.getHost()); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***OK, host is in square brackets=[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210] C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. ***Incorrect, host is not in square brackets=FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 Suggested junit test case: URLTest.java - import java.net.*; import junit.framework.*; public class URLTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(URLTest.class); } public void test_getHost() { URL url=null; String protocol = http; int port = -1; String host = FEDC:BA98:7654:3210:FEDC:BA98:7654:3210; String file = myFile; try { url = new URL(protocol,host,port,file); } catch (Exception e) { fail(Assert 0: URL.URL(protocol,host,port,file) caused: + e); } assertEquals (([+host+]), url.getHost()); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Created: (HARMONY-61) java.net.InetAddress.getByAddress(null) throws NPE insread of UnknownHostException
java.net.InetAddress.getByAddress(null) throws NPE insread of UnknownHostException -- Key: HARMONY-61 URL: http://issues.apache.org/jira/browse/HARMONY-61 Project: Harmony Type: Bug Components: Classlib Reporter: Svetlana Samoilenko According to j2se 1.4.2 specification for java.net.InetAddress.getByAddress(byte[] addr) the method must throw UnknownHostException if IP address is of illegal length. IPv4 address byte array must be 4 bytes long and IPv6 byte array must be 16 bytes long. There is no mention about NPE at all. Mentions about NPE in case of null argument were not found in java.net package specification. The test listed below shows that getByAddress (null) throws NPE. BEA throws UnknownHostException. Code to reproduce: import java.net.*; public class test2 { public static void main (String[] args) { try { InetAddress.getByAddress (null); } catch (UnknownHostException e) { System.out.println(***OK. Expected UnknownHostException. + e); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test2.java using BEA 1.4 javac javac -d . test2.java 3. Run java using compatible VM (J9) java -showversion test2 Output: C:\tmpC:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 java version 1.4.2_04 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) ***OK. UnknownHostException=:java.net.UnknownHostException: addr is of illegal length C:\tmpC:\harmony\trunk\deploy\jre\bin\java -showversion test2 (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. java.lang.NullPointerException at java.net.InetAddress.getByAddress(InetAddress.java:735) at java.net.InetAddress.getByAddress(InetAddress.java:713) at test2.main(test2.java:7) Suggested junit test case: InetAddressTest.java - import java.net.*; import junit.framework.*; public class InetAddressTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(InetAddressTest.class); } public void test_getByAddress() { try { InetAddress.getByAddress (null); fail(Assert 0: UnknownHostException must be thrown); } catch (UnknownHostException e) { } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira