diff options
| author | Jayaprakash Arthanareeswaran | 2013-01-22 09:56:52 +0000 |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2013-01-22 09:57:42 +0000 |
| commit | b14a6c4d09a9bece1bab75937908ff44df19fa09 (patch) | |
| tree | f4fcd0b988b618e973c3a0dc3189d97efdbafab6 | |
| parent | 55ee08ae6c0271dd208dae39ec58d160b498031e (diff) | |
| download | eclipse.jdt.core-b14a6c4d09a9bece1bab75937908ff44df19fa09.tar.gz eclipse.jdt.core-b14a6c4d09a9bece1bab75937908ff44df19fa09.tar.xz eclipse.jdt.core-b14a6c4d09a9bece1bab75937908ff44df19fa09.zip | |
Fix for bug 398272 - PackageFragment.getAttachedJavadoc throwsv20130122-095742I20130127-2000I20130122-0800integration
JavaModelException when there is no Javadoc.
3 files changed, 15 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java index 613c598a24..fdadfe7d8a 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 @@ -93,6 +93,7 @@ public class AttachedJavadocTests extends ModifyingResourceTests { suite.addTest(new AttachedJavadocTests("testBug354766_2")); suite.addTest(new AttachedJavadocTests("testBug394967")); suite.addTest(new AttachedJavadocTests("testBug394382")); + suite.addTest(new AttachedJavadocTests("testBug398272")); return suite; } @@ -1150,4 +1151,15 @@ public class AttachedJavadocTests extends ModifyingResourceTests { this.project.setRawClasspath(oldClasspath, null); } } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=398272 + public void testBug398272() throws JavaModelException { + IPackageFragment packageFragment = this.root.getPackageFragment("p1.p2.p3.p4"); //$NON-NLS-1$ + assertNotNull("Should not be null", packageFragment); //$NON-NLS-1$ + try { + String javadoc = packageFragment.getAttachedJavadoc(new NullProgressMonitor()); //$NON-NLS-1$ + assertNull("Javadoc should be null", javadoc); //$NON-NLS-1$ + } catch(JavaModelException jme) { + fail("Should not throw Java Model Exception"); + } + } } diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachedJavadocProject/lib/test6.jar b/org.eclipse.jdt.core.tests.model/workspace/AttachedJavadocProject/lib/test6.jar Binary files differindex da96f39e76..6f30818ae6 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/AttachedJavadocProject/lib/test6.jar +++ b/org.eclipse.jdt.core.tests.model/workspace/AttachedJavadocProject/lib/test6.jar diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java index 19890befce..5408aef33d 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 @@ -27,7 +27,6 @@ import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaModelStatusConstants; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; @@ -484,7 +483,7 @@ public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelExcep if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); String contents = getURLContents(String.valueOf(pathBuffer)); if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); - if (contents == null) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC, this)); + if (contents == null) return null; contents = (new JavadocContents(contents)).getPackageDoc(); if (contents == null) contents = ""; //$NON-NLS-1$ |
