| Summary: | [DOM] Wrong binding generated for Array.clone() method | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | arlindolima |
| Component: | Core | Assignee: | Jay Arthanareeswaran <jarthana> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | CC: | jarthana, manoj.palat, markus.kell.r, noopur_gupta, Olivier_Thomann, srikanth_sankaran |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | stalebug | ||
|
Description
arlindolima
The declaring class should indeed be Integer[] as shown in the disassembled code:
// Method descriptor #15 ([Ljava/lang/String;)V
// Stack: 2, Locals: 2
public static void main(String[] args);
0 iconst_2
1 anewarray Integer [16]
4 invokevirtual Integer[].clone() : Object [18]
7 checkcast Integer[] [19]
10 astore_1 [a]
11 getstatic System.out : PrintStream [24]
14 aload_1 [a]
15 invokevirtual PrintStream.println(Object) : void [30]
18 return
Investigating what binding we get in this case.
Note that this is true only if the source option is 1.5 or above. In 1.4 or below, the code doesn't compile. Related: An array ITypeBinding's DECLARED_FIELDS and DECLARED_METHODS shouldn't be empty. It should have one filed (length) and one method (clone). (In reply to comment #3) > Related: An array ITypeBinding's DECLARED_FIELDS and DECLARED_METHODS shouldn't > be empty. It should have one filed (length) and one method (clone). I have some problem with this as an array ITypeBinding has no declaring type declaration as is. So I don't see how we can have declared fields or methods. Srikanth, any thoughts on this ? (In reply to comment #4) > (In reply to comment #3) > > Related: An array ITypeBinding's DECLARED_FIELDS and DECLARED_METHODS shouldn't > > be empty. It should have one filed (length) and one method (clone). > I have some problem with this as an array ITypeBinding has no declaring type > declaration as is. So I don't see how we can have declared fields or methods. > > Srikanth, any thoughts on this ? This looks similar to bug 330328. Right now the javadoc on ITypeBinding says: "an array type - array types are referenced but not explicitly declared". Perhaps this could be expanded upon a bit. (In reply to comment #5) > This looks similar to bug 330328. Right now the javadoc on ITypeBinding > says: "an array type - array types are referenced but not explicitly > declared". Perhaps this could be expanded upon a bit. What do you suggest ? (In reply to Olivier Thomann from comment #6) > What do you suggest ? See comment 3. (In reply to Olivier Thomann from comment #4) > I have some problem with this as an array ITypeBinding has no declaring type > declaration as is. So I don't see how we can have declared fields or methods. We already have a type binding for the array type, so it totally makes sense to give it the field and method that are declared in JLS8 10.7. For a type/member to exist in the model, it doesn't have to be declared in a class file. In this snippet, the IMethodBinding for "add" also has a non-null getDeclaringClass(), whose getDeclaredMethods() includes this method again: List<String> al= new ArrayList<>(); al.add("Hi"); And all that although there's no declaration for type List<String> nor for its method with signature "boolean add(String)". This should only be implemented in a new AST#apiLevel(), since existing clients may rely on the "getDeclaringClass() == null" check to find out whether a "length" field is from an array type. Sorry, this needs to be moved out of 4.5. No progress yet and unlikely to get time during 4.6. Moving out. Bulk move out of 4.8 This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |