You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Nellya Udovichenko (JIRA)" <ji...@apache.org> on 2007/01/12 17:38:27 UTC
[jira] Commented: (HARMONY-2418) [classlib][regex]
java.util.regex.Matcher.usePattern(Pattern) throws NPE instead of
specified IllegalArgumentException
[ https://issues.apache.org/jira/browse/HARMONY-2418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464241 ]
Nellya Udovichenko commented on HARMONY-2418:
---------------------------------------------
Please, try the patch.
> [classlib][regex] java.util.regex.Matcher.usePattern(Pattern) throws NPE instead of specified IllegalArgumentException
> -----------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-2418
> URL: https://issues.apache.org/jira/browse/HARMONY-2418
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Artem Aliev
> Attachments: HARMONY-2418-test.patch, HARMONY-2418.patch
>
>
> Problem: According to specification Matcher.usePattern should throw
> IllegalArgumentException when argument is null.
> Test to reproduce:
> import junit.framework.TestCase;
> import java.util.regex.*;
> public class Test extends TestCase {
> public void testcase() {
> Matcher m = Pattern.compile("(.)+"). matcher("as");
> try {
> m.usePattern(null);
> }catch (NullPointerException e) {
> e.printStackTrace();
> fail("Got Unexpected NullPointerException");
> } catch (IllegalArgumentException e) {
> e.printStackTrace();
> System.out.println("Got Expected
> IllegalArgumentException");
> }
> }
> }
> Output on Harmony:
> C:\WS\tst_my>echo off
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software
> Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = rsvn: '.' is not a working copy, (Sep 20 2006), Windows/ia32/msvc 1310,
> release build
> http://incubator.apache.org/harmony
> .java.lang.NullPointerException
> at java.util.regex.Matcher.usePattern(Matcher.java:511)
> at Test.testcase(Test.java:10)
> at java.lang.reflect.VMReflection.invokeMethod(Native Method)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at junit.textui.TestRunner.doRun(TestRunner.java:115)
> at junit.textui.TestRunner.start(TestRunner.java:172)
> at junit.textui.TestRunner.main(TestRunner.java:138)
> F
> Time: 0.016
> There was 1 failure:
> 1) testcase(Test)junit.framework.AssertionFailedError: Got Unexpected
> NullPointerException
> at Test.testcase(Test.java:13)
> at java.lang.reflect.VMReflection.invokeMethod(Native Method)
> FAILURES!!!
> Tests run: 1, Failures: 1, Errors: 0
> res = 1
> Output on RI:
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
> .java.lang.IllegalArgumentException: Pattern cannot be null
> at java.util.regex.Matcher.usePattern(Matcher.java:250)
> at Test.testcase(Test.java:10)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at junit.textui.TestRunner.doRun(TestRunner.java:116)
> at junit.textui.TestRunner.start(TestRunner.java:172)
> at junit.textui.TestRunner.main(TestRunner.java:138)
> Got Expected IllegalArgumentException
> Time: 0.016
> OK (1 test)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira