Project: JDT
Bug 66480 Selecting a badly encoded file in the package explorer results in MalformedInputExceptions
Reported: 2004-06-10 06:25:02 | Status: resolved fixed

I200406091200 - Create a folder with UTF-8 encoding - Have some .java files in the folder that are Latin1 encoded, but with their encoding not set (they inherit from the folder, UTF-8) (-> these files cannot be opened, which is correct) - Selecting the file in the package explorer without opening it Observe the exceptions below (actually many more, as all refactoring actions are updated). The same happens when dragging a correctly encoded file over one of the bad files, e.g. when using drag&drop refactoring. The package explorer should handle this more gracefully. !ENTRY org.eclipse.jdt.ui 4 10001 Jun 10, 2004 12:18:03.825 !MESSAGE Internal Error !STACK 1 org.eclipse.jdt.core.JavaModelException[985]: sun.io.MalformedInputException at java.lang.Throwable.<init>(Throwable.java) at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java) at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java) at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java) at java.io.InputStreamReader.read(InputStreamReader.java) at org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(Util.java) at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java) at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java) at org.eclipse.jdt.internal.core.CompilationUnit.openBuffer(CompilationUnit.java:1029) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:102) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:183) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getChildrenOfType(JavaElement.java) at org.eclipse.jdt.internal.core.CompilationUnit.getTypes(CompilationUnit.java:822) at org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil.getMainType(JavaElementUtil.java) at org.eclipse.jdt.ui.actions.UseSupertypeAction.getSingleSelectedType(UseSupertypeAction.java:114) at org.eclipse.jdt.ui.actions.UseSupertypeAction.canEnable(UseSupertypeAction.java:103) at org.eclipse.jdt.ui.actions.UseSupertypeAction.selectionChanged(UseSupertypeAction.java:81) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionChanged(SelectionDispatchAction.java) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.selectionChanged(SelectionDispatchAction.java) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:157) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1388) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:694) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:720) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:180) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:175) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1362) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1333) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:252) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:334) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:272) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: sun.io.MalformedInputException at java.lang.Throwable.<init>(Throwable.java) at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java) at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java) at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java) at java.io.InputStreamReader.read(InputStreamReader.java) at org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(Util.java) at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java) at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java) at org.eclipse.jdt.internal.core.CompilationUnit.openBuffer(CompilationUnit.java:1029) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:102) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:183) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java) at org.eclipse.jdt.internal.core.JavaElement.getChildrenOfType(JavaElement.java) at org.eclipse.jdt.internal.core.CompilationUnit.getTypes(CompilationUnit.java:822) at org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil.getMainType(JavaElementUtil.java) at org.eclipse.jdt.ui.actions.UseSupertypeAction.getSingleSelectedType(UseSupertypeAction.java:114) at org.eclipse.jdt.ui.actions.UseSupertypeAction.canEnable(UseSupertypeAction.java:103) at org.eclipse.jdt.ui.actions.UseSupertypeAction.selectionChanged(UseSupertypeAction.java:81) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionChanged(SelectionDispatchAction.java) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.selectionChanged(SelectionDispatchAction.java) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:157) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1388) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:694) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:720) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:180) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:175) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1362) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1333) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:252) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:334) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:272) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622)

Files changed in fix:
org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/InlineMethodAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddGetterSetterAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ChangeTypeAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ConvertAnonymousToNestedAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ConvertNestedToTopAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ExtractInterfaceAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FormatAllAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/GenerateNewConstructorUsingFieldsAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OrganizeImportsAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OverrideMethodsAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/RemoveFromClasspathAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/UseSupertypeAction.java