Bug 97209 - [refactoring] JavaModelException when executing Pull Up in generic type
Summary: [refactoring] JavaModelException when executing Pull Up in generic type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Tobias Widmer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 94160
Blocks:
  Show dependency tree
 
Reported: 2005-05-30 06:07 EDT by Tom Hofmann CLA
Modified: 2005-06-09 13:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2005-05-30 06:07:15 EDT
3.1-RC1 test pass

- have the type hierarchy below (note that the two type variables are not connected)
- try to pull up sub from SubType to SuperType
- get the JavaModelException below


------- SuperType.java ---------
package com.example;



public class SuperType<ELEM extends Number> {

	void add(ELEM e) {

	}

	

	ELEM get() {

		return null;

	}

}

------- SubType.java -----------
package com.example;



public class SubType<ELEM> extends SuperType<Integer> {

	void sub(Integer i) {

		add(i);

	}



}

--------------------------------


java.lang.reflect.InvocationTargetException
	at
org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:90)
	at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Caused by: Java Model Exception: Java Model Status [add(Integer)
{key=Lcom/example/SuperType;.add(TELEM;)V} [in SuperType [in [Working copy]
SuperType.java [in com.example [in src [in Generics]]]]] does not exist]
	at
org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:468)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:499)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:232)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:218)
	at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:147)
	at
org.eclipse.jdt.internal.corext.refactoring.structure.MemberVisibilityAdjustor.adjustOutgoingVisibility(MemberVisibilityAdjustor.java:671)
	at
org.eclipse.jdt.internal.corext.refactoring.structure.MemberVisibilityAdjustor.adjustOutgoingVisibility(MemberVisibilityAdjustor.java:690)
	at
org.eclipse.jdt.internal.corext.refactoring.structure.MemberVisibilityAdjustor.adjustOutgoingVisibility(MemberVisibilityAdjustor.java:722)
	at
org.eclipse.jdt.internal.corext.refactoring.structure.MemberVisibilityAdjustor.adjustVisibility(MemberVisibilityAdjustor.java:763)
	at
org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoring.createChangeManager(PullUpRefactoring.java:949)
	at
org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoring.checkFinalConditions(PullUpRefactoring.java:615)
	at
org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84)
	at
org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1719)
	at
org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:86)
	... 1 more
Comment 1 Tom Hofmann CLA 2005-05-30 06:12:19 EDT
Note (1): the same happens if SubType is not a generic type

Note (2): the same works, if SubType.sub(Integer) does not call
SuperType.add(ELEM). In this case, the method is correctly pulled up. The pulled
up method still has an 'Integer' parameter type - one could expect that since
the parameter type corresponds with the type argument to the superclass
specification of SubType, the pull up operation could offer to convert the
method and substitute ELEM as parameter type.
Comment 2 Tom Hofmann CLA 2005-05-30 06:14:45 EDT
Re. the last note (2):

Expanding the parameter type if it is the same as a type argument to the
supertype would make 'Push Down' and 'Pull Up' symmetrical, as the conversion
happens when pushing down: In the example, 'add(ELEM)' is pushed down to
'add(Integer)'.
Comment 3 Dirk Baeumer CLA 2005-05-30 17:21:53 EDT
Tobias, a candidate for 3.2.

How risky is it to fix. I am asking since the visibility adjuster is used in
several other places.
Comment 4 Tobias Widmer CLA 2005-05-31 04:30:07 EDT
ad 1: Its a search problem, see bug 94160

ad 2: This must be fixed
Comment 5 Dirk Baeumer CLA 2005-05-31 05:40:27 EDT
Approved for RC2. If we have to change the MemberVisibilityAdjustor and it is a
larger change then I would prefer that you review it since the code is used in
Move member as well.
Comment 6 Tobias Widmer CLA 2005-05-31 05:45:35 EDT
Just to clarify: Comment 0 is entirely covered by bug 94160, which does not 
involve any changes in JDT UI.

The only thing to fix in the PullUp Refactoring is the renaming of the type 
parameters during pull up.
Comment 7 Dirk Baeumer CLA 2005-05-31 05:48:08 EDT
Thanks for clarification. You consider 94160 a must fix I guess.
Comment 8 Tobias Widmer CLA 2005-05-31 05:51:23 EDT
Yes, the search engine seems to deliver incorrect resolved source methods.
Comment 9 Tobias Widmer CLA 2005-06-06 05:17:31 EDT
Fixed > 20050606
Comment 10 Dirk Baeumer CLA 2005-06-09 13:34:58 EDT
Start verifying...
Comment 11 Dirk Baeumer CLA 2005-06-09 13:37:45 EDT
Verified that the exception doesn't occur anymore. However the generated result
has a compile error in SuperType. Will open a separate bug report (see 99211).