You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Paulex Yang (JIRA)" <ji...@apache.org> on 2006/12/05 18:04:24 UTC

[jira] Updated: (HARMONY-2418) [classlib][regex] java.util.regex.Matcher.usePattern(Pattern) throws NPE instead of specified IllegalArgumentException

     [ http://issues.apache.org/jira/browse/HARMONY-2418?page=all ]

Paulex Yang updated HARMONY-2418:
---------------------------------

    Summary: [classlib][regex] java.util.regex.Matcher.usePattern(Pattern)  throws NPE instead of specified IllegalArgumentException  (was: [regex] java.util.regex.Matcher.usePattern(Pattern)  throws NPE instead of specified IllegalArgumentException)

> [classlib][regex] java.util.regex.Matcher.usePattern(Pattern)  throws NPE instead of specified IllegalArgumentException
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2418
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2418
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Artem Aliev
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira