### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core.tests.model
Index: plugin.xml
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/plugin.xml,v
retrieving revision 1.31
diff -u -r1.31 plugin.xml
--- plugin.xml 27 Feb 2007 17:14:32 -0000 1.31
+++ plugin.xml 10 Jan 2008 17:52:34 -0000
@@ -63,5 +63,14 @@
+
+
+
+
+
+
Index: src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java,v
retrieving revision 1.57
diff -u -r1.57 CompilationUnitTests.java
--- src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 22 Nov 2007 15:05:54 -0000 1.57
+++ src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 10 Jan 2008 17:52:35 -0000
@@ -11,7 +11,12 @@
package org.eclipse.jdt.core.tests.model;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.internal.core.*;
@@ -1170,6 +1175,32 @@
assertSourceEquals("Unexpected contents for non present cu", "", new String(compilationUnit.getContents()));
}
+/*
+ * Ensures that getContents() doesn't throw a NullPointerException for a non-existing cu on a remote file system
+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213427 )
+ */
+public void testGetContentsForNotPresentRemote() throws CoreException, URISyntaxException {
+ IWorkspace workspace = getWorkspace();
+ IProject project = workspace.getRoot().getProject("Foo");
+ try {
+ IProjectDescription description = workspace.newProjectDescription("Foo");
+ description.setLocationURI(new URI("jdt.core.test:///foo"));
+ project.create(description, null);
+ CompilationUnit remoteCU = (CompilationUnit) getCompilationUnit("/Foo/X.java");
+ Exception actual = null;
+ try {
+ remoteCU.getContents();
+ } catch (Exception e) {
+ actual = e;
+ }
+ assertExceptionEquals(
+ "Unexpected exception",
+ "",
+ actual);
+ } finally {
+ project.delete(true, null);
+ }
+ }
/**
* Tests Java element retrieval via source position
*/
Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v
retrieving revision 1.198
diff -u -r1.198 AbstractJavaModelTests.java
--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 9 Jan 2008 14:49:30 -0000 1.198
+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 10 Jan 2008 17:52:35 -0000
@@ -493,8 +493,13 @@
}
assertEquals(message, expected, actual);
}
- protected void assertExceptionEquals(String message, String expected, JavaModelException exception) {
- String actual = exception == null ? "" : exception.getStatus().getMessage();
+ protected void assertExceptionEquals(String message, String expected, Exception exception) {
+ String actual =
+ exception == null ?
+ "" :
+ (exception instanceof CoreException) ?
+ ((CoreException) exception).getStatus().getMessage() :
+ exception.toString();
if (!expected.equals(actual)) {
if (this.displayName) System.out.println(getName()+" actual result is:");
System.out.println(displayString(actual, this.tabs) + this.endChar);
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF,v
retrieving revision 1.3
diff -u -r1.3 MANIFEST.MF
--- META-INF/MANIFEST.MF 2 Aug 2007 01:23:40 -0000 1.3
+++ META-INF/MANIFEST.MF 10 Jan 2008 17:52:35 -0000
@@ -22,6 +22,7 @@
org.eclipse.jdt.core.tests.builder;bundle-version="[3.3.0,4.0.0)",
org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)",
org.eclipse.text;bundle-version="[3.2.0,4.0.0)",
- com.ibm.icu;bundle-version="[3.4.4,4.0.0)"
+ com.ibm.icu;bundle-version="[3.4.4,4.0.0)",
+ org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Index: src/org/eclipse/jdt/core/tests/model/TestFileStore.java
===================================================================
RCS file: src/org/eclipse/jdt/core/tests/model/TestFileStore.java
diff -N src/org/eclipse/jdt/core/tests/model/TestFileStore.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/jdt/core/tests/model/TestFileStore.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.provider.FileInfo;
+import org.eclipse.core.filesystem.provider.FileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class TestFileStore extends FileStore {
+
+ URI uri;
+
+ public TestFileStore(URI uri) {
+ this.uri = uri;
+ }
+
+ public String[] childNames(int options, IProgressMonitor monitor)
+ throws CoreException {
+ return null;
+ }
+
+ public IFileInfo fetchInfo(int options, IProgressMonitor monitor)
+ throws CoreException {
+ return new FileInfo();
+ }
+
+ public IFileStore getChild(String name) {
+ if (name.equals(".project"))
+ return new TestFileStore(this.uri);
+ return new TestFileStore(null);
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public IFileStore getParent() {
+ return new TestFileStore(this.uri);
+ }
+
+ public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
+ return new TestFileStore(this.uri);
+ }
+
+ public InputStream openInputStream(int options, IProgressMonitor monitor)
+ throws CoreException {
+ return null;
+ }
+
+ public OutputStream openOutputStream(int options, IProgressMonitor monitor)
+ throws CoreException {
+ return new OutputStream() {
+ public void write(int b) throws IOException {
+ }
+ };
+ }
+
+ public URI toURI() {
+ return this.uri;
+ }
+
+}
Index: src/org/eclipse/jdt/core/tests/model/TestFileSystem.java
===================================================================
RCS file: src/org/eclipse/jdt/core/tests/model/TestFileSystem.java
diff -N src/org/eclipse/jdt/core/tests/model/TestFileSystem.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/jdt/core/tests/model/TestFileSystem.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.model;
+
+import java.net.URI;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.provider.FileSystem;
+
+public class TestFileSystem extends FileSystem {
+
+ public IFileStore getStore(URI uri) {
+ return new TestFileStore(uri);
+ }
+
+}
#P org.eclipse.jdt.core
Index: model/org/eclipse/jdt/internal/core/util/Util.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java,v
retrieving revision 1.113
diff -u -r1.113 Util.java
--- model/org/eclipse/jdt/internal/core/util/Util.java 4 Dec 2007 11:10:12 -0000 1.113
+++ model/org/eclipse/jdt/internal/core/util/Util.java 10 Jan 2008 17:52:38 -0000
@@ -1045,7 +1045,10 @@
if (location == null) {
// non local file
try {
- length = EFS.getStore(file.getLocationURI()).fetchInfo().getLength();
+ URI locationURI = file.getLocationURI();
+ if (locationURI == null)
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, file.getFullPath() + Messages.util_doesntExist));
+ length = EFS.getStore(locationURI).fetchInfo().getLength();
} catch (CoreException e) {
throw new JavaModelException(e);
}
Index: model/org/eclipse/jdt/internal/core/util/messages.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties,v
retrieving revision 1.68
diff -u -r1.68 messages.properties
--- model/org/eclipse/jdt/internal/core/util/messages.properties 19 Oct 2007 15:57:22 -0000 1.68
+++ model/org/eclipse/jdt/internal/core/util/messages.properties 10 Jan 2008 17:52:38 -0000
@@ -366,3 +366,4 @@
classfileformat_exceptiontableentry = [pc: {0}, pc: {1}] -> {2} when : {3}
classfileformat_linenumbertableentry = [pc: {0}, line: {1}]
classfileformat_localvariabletableentry = [pc: {0}, pc: {1}] local: {2} index: {3} type: {4}
+util_doesntExist=\ doesn't exist
Index: model/org/eclipse/jdt/internal/core/util/Messages.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Messages.java,v
retrieving revision 1.19
diff -u -r1.19 Messages.java
--- model/org/eclipse/jdt/internal/core/util/Messages.java 19 Oct 2007 15:57:22 -0000 1.19
+++ model/org/eclipse/jdt/internal/core/util/Messages.java 10 Jan 2008 17:52:37 -0000
@@ -333,6 +333,7 @@
public static String disassembler_frame_full_frame;
public static String disassembler_frame_same_frame;
public static String disassembler_frame_same_locals_1_stack_item;
+ public static String util_doesntExist;
static {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);