harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-5622) [drlvm][kernel][geronimo] Method.getGeneric*() methods throw NPE for parametrized interface methods
Date Thu, 20 Mar 2008 14:51:25 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-5622?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Vasily Zakharov updated HARMONY-5622:
-------------------------------------

    Attachment: Harmony-5622.patch

Attached a fix patch. It's rather big and contains the following changes:

1. Resolves the issue itself making sure the class is checked for null before getTypeParameters()
is called.

2. Redesigns the findGenericDeclarationForTypeVariable() by unifying the handling for Class,
Field, Method and Constructor wherever possible and moving parts of functionality to a separate
hasGenericDeclaration() method.

3. Redesigns the findTypeVariable() method by unifying the handling for Class, Field, Method
and Constructor wherever possible and moving parts of functionality to a separate findTypeVariableInDeclaration()
method.

4. Fixes a number of minor formatting issues like no space between 'if' or 'for' and (, or
between ) and {.

As a result of changes 2 and 3 the patched file is half that big as original one.

The patch was checked briefly but not thoroughly, so it's just a draft for now. I'll check
it more carefully later.

I would be grateful if someone from VM gurus reviews the patch. Thank you!


> [drlvm][kernel][geronimo] Method.getGeneric*() methods throw NPE for parametrized interface
methods
> ---------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5622
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5622
>             Project: Harmony
>          Issue Type: Bug
>          Components: App-Oriented Bug Reports, DRLVM
>    Affects Versions: 5.0M5
>            Reporter: Vasily Zakharov
>            Assignee: Vasily Zakharov
>            Priority: Critical
>         Attachments: Harmony-5622.patch
>
>
> Class Method methods getGenericParameterTypes(), getGenericReturnType() and toGenericString()
throw NPE if called for a parametrized method in an interface.
> Here's the test demonstrating the problem:
> import java.lang.reflect.Method;
> public class Test {
>     public static void main(String[] args) {
>         boolean success = true;
>         try {
>             Method method = Sample.class.getMethods()[0];
>             for (int i = 0; i < 5; i++) {
>                 try {
>                     switch (i) {
>                     case 0: method.getGenericParameterTypes();
>                             break;
>                     case 1: method.getGenericReturnType();
>                             break;
>                     case 2: method.getGenericExceptionTypes();
>                             break;
>                     case 3: method.getTypeParameters();
>                             break;
>                     case 4: method.toGenericString();
>                             break;
>                     }
>                 } catch (Exception e) {
>                     success = false;
>                     System.out.print("FAIL: ");
>                     e.printStackTrace(System.out);
>                 }
>             }
>             System.out.println(success ? "SUCCESS" : "FAILURE");
>         } catch (Exception e) {
>             System.out.print("ERROR: ");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> interface Sample {
>     public <T extends Sample, E extends Throwable> T test(T param) throws E;
> }
> Output on RI:
> SUCCESS
> Output on Harmony:
> FAIL: java.lang.NullPointerException
>         at org.apache.harmony.lang.reflect.support.AuxiliaryFinder.findTypeVariable(AuxiliaryFinder.java:293)
>         at org.apache.harmony.lang.reflect.parser.Parser.getGenericParameterTypes(Parser.java:742)
>         at java.lang.reflect.Method.getGenericParameterTypes(Method.java:110)
>         at Test.main(Test.java:10)
> FAIL: java.lang.NullPointerException
>         at org.apache.harmony.lang.reflect.support.AuxiliaryFinder.findTypeVariable(AuxiliaryFinder.java:293)
>         at org.apache.harmony.lang.reflect.parser.Parser.getGenericReturnTypeImpl(Parser.java:447)
>         at java.lang.reflect.Method.getGenericReturnType(Method.java:126)
>         at Test.main(Test.java:12)
> FAIL: java.lang.NullPointerException
>         at org.apache.harmony.lang.reflect.support.AuxiliaryFinder.findTypeVariable(AuxiliaryFinder.java:293)
>         at org.apache.harmony.lang.reflect.parser.Parser.getGenericParameterTypes(Parser.java:742)
>         at java.lang.reflect.Method.toGenericString(Method.java:150)
>         at Test.main(Test.java:18)
> FAILURE
> This issue is critical as it prevents Geronimo Deployer from working on Harmony.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message