This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 58358 - Java Language Model Apis require lots of boiler plate
Summary: Java Language Model Apis require lots of boiler plate
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-26 22:18 UTC by ischneid
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
testcase (9.32 KB, text/plain)
2005-04-27 00:33 UTC, ischneid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ischneid 2005-04-26 22:18:28 UTC
In attempts to port a simple delegation code-writer tool from the javasrc apis
to the jmi apis, I ran into alot of boiler plate code. The problem arises when
one attempts to add methods from a reflection-based JavaClass to a text-based
JavaClass. What was a 200 line class (including imports and a 25 line testing
main) exploded to 400 lines after wholesale copy of the boilerplate contained in
org.netbeans.modules.java.tools.JMIInheritanceSupport. Without recreating all of
the various List(s) of Parameters, Annotations, etc., one receives
javax.jmi.reflect.CompositionViolationException when attempting to add methods
to a class. It would be ideal if either a) The jmi implementations were able to
deal with this or b) There were public utilities to replace the boiler plate
copying, etc.
Comment 1 Martin Matula 2005-04-26 22:34:55 UTC
I am not sure what you mean by the reflection-based and text-based JavaClass.
Doesn't the Element.duplicate() method work for you? That should create a deep
copy of the element so that you should not have to recreate the individual
elements yourself.
Automatic detection and creation of elements for this would be confusing since
"setSomething(aaa); assert aaa == getSomething();" would fail.
Comment 2 ischneid 2005-04-27 00:32:20 UTC
I guess I don't know what I mean (but I thought for some reason that there  
were both source and reflection based implementations - somewhere in my 
tinkering I was receiving ClassCastExceptions from within the implementation) 
but thats besides the point. 
 
The attached class demonstrates my attempts to add methods from one class to  
another. Notes are in the class javadoc. 
  
For my particular problem, I can solve it using JMIInheritanceSupport directly  
and then looking up the methods it overrode and providing the delegation  
behavior. But in general, it would just be nice if some of the functionality  
provided by JMInheritanceSupport were provided in some JMI utilities API.  
  
Understand comments about setSomething(aaa); assert aaa == getSomething(); 
but what about 
assert aaa.equals(getSomething()) ? 
Comment 3 ischneid 2005-04-27 00:33:21 UTC
Created attachment 21886 [details]
testcase
Comment 4 Pavel Flaska 2005-10-25 14:07:46 UTC
We could provide utility methods, but nobody work on it right now. We have to
collect requirements from all JMI users and make together a specification of the
most common cases. Currently, we make the utility methods used by us in
JavaModelUtil class. This is not API because it is does not go through API process.

Seems to me it is not a bug, because there is no broken functionality. Changing
to ENHANCEMENT and increasing priority.
Comment 5 Jiri Prox 2007-09-12 09:05:33 UTC
The JMI is not used any more