Bug 190508 - [infer type arguments] Infer Generics Refactoring Broken
Summary: [infer type arguments] Infer Generics Refactoring Broken
Status: RESOLVED DUPLICATE of bug 211037
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows Vista
: P3 major (vote)
Target Milestone: 3.4   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-01 13:13 EDT by Adam Cabler CLA
Modified: 2008-01-28 04:48 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Cabler CLA 2007-06-01 13:13:48 EDT
I tried to use the generics refactor wizard in RC2, but when I click either preview, or OK, it churns for a while and gives an error dialog. Here is the trace from the log:

java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:350)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:310)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:553)
at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:154)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:619)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:439)
at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:464)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:616)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:142)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:154)
at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:49)
at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startInferTypeArgumentsRefactoring(RefactoringExecutionStarter.java:312)
at org.eclipse.jdt.ui.actions.InferTypeArgumentsAction.run(InferTypeArgumentsAction.java:114)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:268)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:244)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:229)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:234)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
Caused by: java.lang.UnsupportedOperationException
at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.WildcardType.getSubTypes(WildcardType.java:39)
at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.SubTypesOfSingleton.isSingleton(SubTypesOfSingleton.java:226)
at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet.superTypes(TypeSet.java:163)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.maintainSimpleConstraint(InferTypeArgumentsConstraintsSolver.java:248)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.processConstraints(InferTypeArgumentsConstraintsSolver.java:224)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.runSolver(InferTypeArgumentsConstraintsSolver.java:201)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.solveConstraints(InferTypeArgumentsConstraintsSolver.java:128)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring.checkFinalConditions(InferTypeArgumentsRefactoring.java:228)
at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83)
at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:118)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Root exception:
java.lang.UnsupportedOperationException
at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.WildcardType.getSubTypes(WildcardType.java:39)
at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.SubTypesOfSingleton.isSingleton(SubTypesOfSingleton.java:226)
at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet.superTypes(TypeSet.java:163)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.maintainSimpleConstraint(InferTypeArgumentsConstraintsSolver.java:248)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.processConstraints(InferTypeArgumentsConstraintsSolver.java:224)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.runSolver(InferTypeArgumentsConstraintsSolver.java:201)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver.solveConstraints(InferTypeArgumentsConstraintsSolver.java:128)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring.checkFinalConditions(InferTypeArgumentsRefactoring.java:228)
at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83)
at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:118)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Comment 1 Martin Aeschlimann CLA 2007-06-04 04:07:59 EDT
Can you extract a (small) code example where this happens?
Comment 2 Adam Cabler CLA 2007-06-04 12:42:17 EDT
(In reply to comment #1)
> Can you extract a (small) code example where this happens?
> 

I did some more testing.  This seems to work with a few files, but when I give it a project with about 200 hundred files and about 2K generics warnings, I get this error.
Comment 3 Stephan Herrmann CLA 2007-09-22 12:50:12 EDT
I'm seeing the same stacktrace in 3.3.

While trying to reproduce this in a small example I got a
"This refactoring does not change any source code." where it
obviously _could_ easily change the code. Here is the example:

import java.util.Iterator;
public class BrokenInferGenerics {
    Iterator<BrokenInferGenerics> getAll() {
        return null;
    }
    static void foo(BrokenInferGenerics big) {
        Iterator it= big.getAll(); // try to infer parameter here.
        while(it.hasNext()) {
            BrokenInferGenerics next= (BrokenInferGenerics) it.next();
        }
    }
}

The snippet looks the same as the bigger example throwing above exception.
I'm trying to get another one that shows the exception.
Maybe both problems are related..
Comment 4 Stephan Herrmann CLA 2007-09-22 13:37:36 EDT
OK, here's an example that produces above UnsupportedOperationException:

import java.util.Iterator;
public class BrokenInferGenerics {
	Iterator<BrokenInferGenerics> getAll() {
		return null;
	}
	static void foo(BrokenInferGenerics big, Object o) {
		if (o.getClass() == String.class)
			return;
		Iterator it= big.getAll();
		while(it.hasNext()) {
			BrokenInferGenerics next= (BrokenInferGenerics) it.next();
		}
	}
}

The top part of my trace differs (seeing 
  RefactoringWizard.createChange(RefactoringWizard.java:579)
instead of 
  RefactoringWizard.internalPerformFinish(RefactoringWizard.java:553)
but the root exception seems to be the same.

It must relate to special treatment of o.getClass() if o is of type Object.
No other type seems to produce this error. Debugging this I see an
unbounded "<?>" as an upper bound in a type constraint, which doesn't seem 
to make much sense, but I'm not familiar with the type constraint resolver ;-)

Since the problem from my comment#3 seems to be unrelated, should I
create a new issue for it?
Comment 5 Dani Megert CLA 2008-01-28 04:48:43 EST

*** This bug has been marked as a duplicate of bug 211037 ***