bugKawa - Bugs: bug #42713, ...

 
 

bug #42713: MalformedParameterizedTypeException thrown when compiling

Submitted by:  Matthieu Vachon <maoueh>
Submitted on:  Wed 09 Jul 2014 02:35:40 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 10 Jul 2014 04:58:26 PM UTC, comment #5:

> As far as I can tell, it's not actually malformed. Rather the issue appears to be that Kawa can't access teh classes involved.


I think I might have understand the problem. The following java snippet fails with MalformedException:

But this one fails with `error: type ServiceRegistration does not take parameters`:

It appears that `ResourcesPlugin` was compiled with Java5 while `ServiceRegistration` with Java4. Hence, this might explain why the call to `getGenericType` fails when trying to access `ServiceRegistration` generic type.

I'm not sure I understand the reasoning with the permission check. What kind of permission would Kawa check exactly?

Matthieu Vachon <maoueh>
Thu 10 Jul 2014 03:45:46 PM UTC, comment #4:

> It sure it ain't Kawa faults if the class is malformed, but Kawa should deal with it the best it can.


As far as I can tell, it's not actually malformed. Rather the issue appears to be that Kawa can't access teh classes involved.

> I don't think it's enough. It will work with this particular test case, but if another similar classes is encountered, but this time has a protected or public field, it will still fail.
> The `rfield.getGenericType()` now in `gnu/bytecode/Field.java` will still throw an exception in such potential case.


But now the exception is only thrown if you actually access the field. In which case an exception might not be out of place. Still, I agree a friendlier error message would help.

However, there is a reasonable hope that Kawa will do a permission check before it calls getType, in which case the current code is ok.

I'll think about it, but it would help if you could force an "unfriendly" exception message (rather than a "friendly" permission-failed message).

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 10 Jul 2014 03:11:43 PM UTC, comment #3:

> The Exception was not about a kawa-generated field, but one in the Eclipse classes.


I know, I though it was clear in my first email, sorry.

> I actually checked in two fixes, either of which should work, but both make sense for performance reasons


I don't think it's enough. It will work with this particular test case, but if another similar classes is encountered, but this time has a protected or public field, it will still fail.

The `rfield.getGenericType()` now in `gnu/bytecode/Field.java` will still throw an exception in such potential case.

It sure it ain't Kawa faults if the class is malformed, but Kawa should deal with it the best it can.

The call to `getGenericType` should be wrap in a try/catch to traps `MalformedParameterizedTypeException` and act accordingly when it happens. When such exception is raised, Kawa could assume the field is not generic, assume the field's generic type is Object or stop compilation with a more "user-friendly" message.

Matthieu Vachon <maoueh>
Thu 10 Jul 2014 02:41:06 PM UTC, comment #2:

The Exception was not about a kawa-generated field, but one in the Eclipse classes. As far as I can tell, it's not really a "malformed parameterized type". I'm guessing the problem might be related access-permissions issue - for one thing, the field itself is private, so it's silly to resolve its type.

I actually checked in two fixes, either of which should work, but both make sense for performance reasons:
(1) Make the call getGenericType lazy -i.e. defer until getType is called.
(2) skip private fields (which the documentation states, but we didn't do).

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Wed 09 Jul 2014 02:45:52 AM UTC, comment #1:

I'm completely unable to attach the archive to the bug report. No error message appears but after submit, the archive is never attached.

I uploaded it to my Google drive account, here the link:

https://drive.google.com/file/d/0B_zzArQGaVwQSjMwbW55YndpWGc/edit?usp=sharing

Then `File > Download` (or simply Ctrl+S) to download archive.

Matthieu Vachon <maoueh>
Wed 09 Jul 2014 02:35:40 AM UTC, original submission:

When compiling this simple test case, the compiler throws a `java.lang.reflect.MalformedParameterizedTypeException`:

;; testcase.scm
(static-field <org.eclipse.core.resources.ResourcesPlugin> 'PI_RESOURCES)

The offending field in class `org.eclipse.core.resources.ResourcesPlugin` is `private
ServiceRegistration<IWorkspace> workspaceRegistration`.

The attached archive contains the following content for reproducing this bug:

  • testcase.scm - Simple test case to compile.
  • testcase.sh - Bash script setuping the classpath.
  • *.jar - The Eclipse jars required for compilation.
  • *.class - The compiled class files extracted from the jars.
  • *.java - The source file for the extracted class files.

Classes `IWorkspace` and `ResourcesPlugin` comes from `org.eclipse.core.resources.jar` and `ServiceRegistration` from `org.eclipse.osgi.jar`.

Tell me if you need anything else.

The full exception stack trace is the following:

Matt

Matthieu Vachon <maoueh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  • -unavailable- added by maoueh (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 31 Jul 2014 02:52:07 PM UTCbothnerOpen/ClosedOpen=>Closed
    Thu 10 Jul 2014 03:45:46 PM UTCbothnerOpen/ClosedClosed=>Open
    Thu 10 Jul 2014 02:41:06 PM UTCbothnerStatusNone=>Fixed
      Assigned toNone=>bothner
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1