[janino-dev] [jira] Created: (JANINO-90) Make use of initCause in class$, if available.

View: New views
6 Messages — Rating Filter:   Alert me  

[janino-dev] [jira] Created: (JANINO-90) Make use of initCause in class$, if available.

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Make use of initCause in class$, if available.
----------------------------------------------

                 Key: JANINO-90
                 URL: http://jira.codehaus.org/browse/JANINO-90
             Project: Janino
          Issue Type: New Feature
            Reporter: Adam Heath
            Assignee: Arno Unkrig
            Priority: Trivial
         Attachments: feature_use_initCause_in_class$_method.patch

If initCause is available(java 1.4), the use that to initialize chained exceptions in class$ method.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-90) Make use of initCause in class$, if available.

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_96322 ]

Arno Unkrig commented on JANINO-90:
-----------------------------------

Hm... does JAVAC do that too? I don't think so... Is it really needed?

Also, I believe that "NoClassDefFoundError.class" is risky in that context, because it may lead to endless recursion. Better write "ncdfe.getClass()".

> Make use of initCause in class$, if available.
> ----------------------------------------------
>
>                 Key: JANINO-90
>                 URL: http://jira.codehaus.org/browse/JANINO-90
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Trivial
>         Attachments: feature_use_initCause_in_class$_method.patch
>
>
> If initCause is available(java 1.4), the use that to initialize chained exceptions in class$ method.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-90) Make use of initCause in class$, if available.

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_96417 ]

Adam Heath commented on JANINO-90:
----------------------------------

Um, you *can't* write ncfde.getClass().  It's static.  There's no danger of recursion.  It's a class from java.lang; it will not be loaded by janino.

As for it being needed, if there is an error loading the class, then it's this *new* error that is the cause of the problem.  Just throwing a NCFDE here will not help in solving the real problem.  Consider the case where the class that was initially requested parsed, compiled, and was loaded, but then it's static initialization block throws an Error or RuntimeException, when it tries to access another class in it's package, that is also being handled by janino.  In this case, the other class parses and compiled fine, but fails verification, because janino is not a valid compiler.

That verification failure most often occurs because janino doesn't have proper variable/method resolution, when it comes to implicit methods access by 'this'.

> Make use of initCause in class$, if available.
> ----------------------------------------------
>
>                 Key: JANINO-90
>                 URL: http://jira.codehaus.org/browse/JANINO-90
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Trivial
>         Attachments: feature_use_initCause_in_class$_method.patch
>
>
> If initCause is available(java 1.4), the use that to initialize chained exceptions in class$ method.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-90) Make use of initCause in class$, if available.

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_99245 ]

Arno Unkrig commented on JANINO-90:
-----------------------------------

{quote}
Um, you can't write ncfde.getClass(). It's static.
{quote}
{code}
 "   } catch (ClassNotFoundException ex) {\n" +
-"       throw new NoClassDefFoundError(ex.getMessage());\n" +
+"       NoClassDefFoundError ncdfe = new NoClassDefFoundError(ex.getMessage());\n" +
+"       try {\n" +
+"           java.lang.reflect.Method initCauseMethod = NoClassDefFoundError.class.getMethod(\"initCause\", new Class[] {Throwable.class});\n" +
+"           initCauseMethod.invoke(ncdfe, new Object[] {ex});\n" +
+"       } catch (Exception e) {\n" +
+"       }\n" +
+"       throw ncdfe;\n" +
 "   }\n" +
{code}
??? "ncdfe" is a local variable, so it should indeed be possible to call "ncdfe.getClass()".
{quote}
There's no danger of recursion. It's a class from java.lang; it will not be loaded by janino.
{quote}
Anything that can go wrong, will go wrong ;-)
{quote}
As for it being needed, if there is an error loading the class, then it's this new error that is the cause of the problem. Just throwing a NCFDE here will not help in solving the real problem. Consider the case where the class that was initially requested parsed, compiled, and was loaded, but then it's static initialization block throws an Error or RuntimeException, when it tries to access another class in it's package, that is also being handled by janino. In this case, the other class parses and compiled fine, but fails verification, because janino is not a valid compiler.
{quote}
You're right, especially when using JavaSourceClassLoader, it is extremely interesting to get more information about than the dumb NoClassDefFoundError.

My question is: Have you checked how JAVAC (1.2, 3, 4, 5, 6) do it? It's a good idea to stick to (or at least look at) JAVAC's strategy to implement a tricky feature like this.
{quote}
That verification failure most often occurs because janino doesn't have proper variable/method resolution, when it comes to implicit methods access by 'this'.
{quote}
How far is JANINO's resolution of variables/methods improper? My aim is that JANINO implements these exactly like JAVAC, so if it doesn't please let me know (i.e. file a JIRA issue).


CU

Arno

> Make use of initCause in class$, if available.
> ----------------------------------------------
>
>                 Key: JANINO-90
>                 URL: http://jira.codehaus.org/browse/JANINO-90
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Trivial
>         Attachments: feature_use_initCause_in_class$_method.patch
>
>
> If initCause is available(java 1.4), the use that to initialize chained exceptions in class$ method.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-90) Make use of initCause in class$, if available.

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_117861 ]

Arno Unkrig commented on JANINO-90:
-----------------------------------

Any activitty on this one?

> Make use of initCause in class$, if available.
> ----------------------------------------------
>
>                 Key: JANINO-90
>                 URL: http://jira.codehaus.org/browse/JANINO-90
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Trivial
>         Attachments: feature_use_initCause_in_class$_method.patch
>
>
> If initCause is available(java 1.4), the use that to initialize chained exceptions in class$ method.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-90) Make use of initCause in class$, if available.

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=145929#action_145929 ]

Adam Heath commented on JANINO-90:
----------------------------------

I'll work on doing AST stuff, instead of doing it as a string.  Unless someone else beats me to it.

> Make use of initCause in class$, if available.
> ----------------------------------------------
>
>                 Key: JANINO-90
>                 URL: http://jira.codehaus.org/browse/JANINO-90
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Trivial
>         Attachments: feature_use_initCause_in_class$_method.patch
>
>
> If initCause is available(java 1.4), the use that to initialize chained exceptions in class$ method.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email