Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 20768 Details for
Bug 83739
[1.5] support @SuppressWarnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
SuppressWarnings annotations tests
patch_org.eclipse.jdt.core.tests.compiler_01.txt (text/plain), 10.47 KB, created by
Maxime Daniel
on 2005-05-06 07:26:26 EDT
(
hide
)
Description:
SuppressWarnings annotations tests
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2005-05-06 07:26:26 EDT
Size:
10.47 KB
patch
obsolete
>Index: AnnotationTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.83 >diff -u -r1.83 AnnotationTest.java >--- AnnotationTest.java 4 May 2005 13:24:45 -0000 1.83 >+++ AnnotationTest.java 6 May 2005 11:15:01 -0000 >@@ -12,6 +12,7 @@ > > import java.io.File; > import java.io.IOException; >+import java.util.Hashtable; > import java.util.Map; > > import junit.framework.Test; >@@ -4090,5 +4091,286 @@ > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + > "----------\n"); >+ } >+ // check @SuppressWarning support >+ public void test130() { >+ Map customOptions = new Hashtable(); >+ String[] warnings = CompilerOptions.warningOptionNames(); >+ for (int i = 0, ceil = warnings.length; i < ceil; i++) { >+ customOptions.put(warnings[i], CompilerOptions.WARNING); >+ } >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 1)\n" + >+ " public class X {\n" + >+ " ^\n" + >+ "Javadoc: Missing comment for public declaration\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 2)\n" + >+ " public static void main(String[] args) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Javadoc: Missing comment for public declaration\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 2)\n" + >+ " public static void main(String[] args) {\n" + >+ " }\n" + >+ " ^^^^^\n" + >+ "Empty block should be documented\n" + >+ "----------\n", >+ null, true, customOptions); > } >+ // check @SuppressWarning support >+ public void test131() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "@SuppressWarnings(\"all\")\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " Zork z;\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n"); >+ } >+ // check @SuppressWarning support >+ public void test132() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.io.Serializable;\n" + >+ "import java.util.List;\n" + >+ "import java.util.Vector;\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " W.deprecated();\n" + >+ " List<X> l = new Vector();\n" + >+ " l.size();\n" + >+ " try {\n" + >+ " // do nothing\n" + >+ " } finally {\n" + >+ " throw new Error();\n" + >+ " }\n" + >+ " // Zork z;\n" + >+ " }\n" + >+ "\n" + >+ " class S implements Serializable {\n" + >+ " String dummy;\n" + >+ " }\n" + >+ "}", >+ "W.java", >+ "public class W {\n" + >+ " // @deprecated\n" + >+ " @Deprecated\n" + >+ " static void deprecated() {\n" + >+ " // do nothing\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 7)\n" + >+ " W.deprecated();\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The method deprecated() from the type W is deprecated\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 8)\n" + >+ " List<X> l = new Vector();\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Type safety: The expression of type Vector needs unchecked conversion to conform to List<X>\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 12)\n" + >+ " } finally {\n" + >+ " throw new Error();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "finally block does not complete normally\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 18)\n" + >+ " class S implements Serializable {\n" + >+ " ^\n" + >+ "The serializable class S does not declare a static final serialVersionUID field of type long\n" + >+ "----------\n"); >+ } >+ // check @SuppressWarning support >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=89436 >+ public void test133() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.io.Serializable;\n" + >+ "import java.util.List;\n" + >+ "import java.util.Vector;\n" + >+ "\n" + >+ "@SuppressWarnings( { \"deprecation\",//$NON-NLS-1$\n" + >+ " \"finally\",//$NON-NLS-1$\n" + >+ " \"serial\",//$NON-NLS-1$\n" + >+ " \"unchecked\"//$NON-NLS-1$\n" + >+ "})\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " W.deprecated();\n" + >+ " List<X> l = new Vector();\n" + >+ " l.size();\n" + >+ " try {\n" + >+ " // do nothing\n" + >+ " } finally {\n" + >+ " throw new Error();\n" + >+ " }\n" + >+ " Zork z;\n" + >+ " }\n" + >+ "\n" + >+ " class S implements Serializable {\n" + >+ " String dummy;\n" + >+ " }\n" + >+ "}", >+ "W.java", >+ "public class W {\n" + >+ " // @deprecated\n" + >+ " @Deprecated\n" + >+ " static void deprecated() {\n" + >+ " // do nothing\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 20)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n"); >+ } >+ // check @SuppressWarning support - NOT READY YET: field support >+ public void test134() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.io.Serializable;\n" + >+ "import java.util.List;\n" + >+ "import java.util.Vector;\n" + >+ "\n" + >+ "public class X {\n" + >+ " @SuppressWarnings( { \"deprecation\",//$NON-NLS-1$\n" + >+ " \"finally\",//$NON-NLS-1$\n" + >+ " \"unchecked\"//$NON-NLS-1$\n" + >+ " })\n" + >+ " public static void main(String[] args) {\n" + >+ " W.deprecated();\n" + >+ " List<X> l = new Vector();\n" + >+ " l.size();\n" + >+ " try {\n" + >+ " // do nothing\n" + >+ " } finally {\n" + >+ " throw new Error();\n" + >+ " }\n" + >+ " Zork z;\n" + >+ " }\n" + >+ "\n" + >+ " // not ready yet: field support\n" + >+ " @SuppressWarnings(\"unchecked\"//$NON-NLS-1$\n" + >+ " )\n" + >+ " List<X> l = new Vector();\n" + >+ "\n" + >+ " @SuppressWarnings(\"serial\"//$NON-NLS-1$\n" + >+ " )\n" + >+ " class S implements Serializable {\n" + >+ " String dummy;\n" + >+ " }\n" + >+ "}", >+ "W.java", >+ "public class W {\n" + >+ " // @deprecated\n" + >+ " @Deprecated\n" + >+ " static void deprecated() {\n" + >+ " // do nothing\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 19)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 25)\n" + >+ " List<X> l = new Vector();\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Type safety: The expression of type Vector needs unchecked conversion to conform to List<X>\n" + >+ "----------\n"); >+ } >+ // check @SuppressWarning support >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=69505 -- NOT READY YET: "all" only so far, no file support -- >+ // hence no import support >+ // MDL->PMT: should we check that the warnings are emitted when the annotation is not present (aka test132)? if yes, >+ // a single test or multiple ones? >+ public void test135() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.List;\n" + >+ "\n" + >+ "@SuppressWarnings(\"all\"//$NON-NLS-1$\n" + >+ ")\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " if (false) {\n" + >+ " ;\n" + >+ " } else {\n" + >+ " }\n" + >+ " Zork z;\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 1)\n" + >+ " import java.util.List;\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The import java.util.List is never used\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 11)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n"); >+ } >+ // check @SuppressWarning support >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=71968 -- NOT READY YET, preparing for it >+ public void test136() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " @SuppressWarnings(\"unusedPrivate\"//$NON-NLS-1$\n" + >+ " )\n" + >+ " private static final String marker = \"never used mark\"; //$NON-NLS-1$\n" + >+ "\n" + >+ " public static void main(String[] args) {\n" + >+ " Zork z;\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " private static final String marker = \"never used mark\"; //$NON-NLS-1$\n" + >+ " ^^^^^^\n" + >+ "The private field X.marker is never read locally\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n"); >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 83739
:
20767
| 20768