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 54573 Details for
Bug 165954
[API] JavaCore should have an option to set the compiler's settings according to a compliance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_165954.txt (text/plain), 8.80 KB, created by
Olivier Thomann
on 2006-11-27 14:28:01 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-11-27 14:28:01 EST
Size:
8.80 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.556 >diff -u -r1.556 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 23 Nov 2006 17:27:18 -0000 1.556 >+++ model/org/eclipse/jdt/core/JavaCore.java 27 Nov 2006 19:26:37 -0000 >@@ -103,6 +103,8 @@ > import org.eclipse.jdt.core.search.SearchEngine; > import org.eclipse.jdt.core.search.SearchPattern; > import org.eclipse.jdt.core.search.TypeNameRequestor; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > import org.eclipse.jdt.internal.core.*; > import org.eclipse.jdt.internal.core.builder.JavaBuilder; >@@ -998,6 +1000,12 @@ > /** > * Possible configurable option value. > * @see #getDefaultOptions() >+ * @since 3.3 >+ */ >+ public static final String VERSION_1_7 = "1.7"; //$NON-NLS-1$ >+ /** >+ * Possible configurable option value. >+ * @see #getDefaultOptions() > * @since 2.0 > */ > public static final String ABORT = "abort"; //$NON-NLS-1$ >@@ -1738,7 +1746,7 @@ > * Select the compliance level for the compiler. In "1.3" mode, source and target settings > * should not go beyond "1.3" level. > * - option id: "org.eclipse.jdt.core.compiler.compliance" >- * - possible values: { "1.3", "1.4", "1.5", "1.6" } >+ * - possible values: { "1.3", "1.4", "1.5", "1.6", "1.7" } > * - default: "1.4" > * > * COMPILER / Setting Source Compatibility Mode >@@ -1750,16 +1758,19 @@ > * and the compliance mode should be "1.5". > * Source level 1.6 is necessary to enable the computation of stack map tables. Once toggled, the target > * VM level should be set to "1.6" and the compliance mode should be "1.6". >+ * Once the source level 1.7 is toggled, the target VM level should be set to "1.7" and the compliance mode >+ * should be "1.7". > * - option id: "org.eclipse.jdt.core.compiler.source" >- * - possible values: { "1.3", "1.4", "1.5", "1.6" } >+ * - possible values: { "1.3", "1.4", "1.5", "1.6", "1.7" } > * - default: "1.3" > * > * COMPILER / Defining Target Java Platform > * For binary compatibility reason, .class files can be tagged to with certain VM versions and later. > * Note that "1.4" target requires to toggle compliance mode to "1.4", "1.5" target requires >- * to toggle compliance mode to "1.5" and "1.6" target requires to toggle compliance mode to "1.6". >+ * to toggle compliance mode to "1.5", "1.6" target requires to toggle compliance mode to "1.6" and >+ * "1.7" target requires to toggle compliance mode to "1.7". > * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform" >- * - possible values: { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6" } >+ * - possible values: { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7" } > * - default: "1.2" > * > * COMPILER / Generating Local Variable Debug Attribute >@@ -4204,15 +4215,78 @@ > } > > /** >- * Sets the current table of options. All and only the options explicitly included in the given table >- * are remembered; all previous option settings are forgotten, including ones not explicitly >- * mentioned. >- * <p> >- * For a complete description of the configurable options, see <code>getDefaultOptions</code>. >+ * Sets the default's compiler options inside the given options map according >+ * to the given compliance. >+ * >+ * <p>The given compliance must be one of the compliance supported by the compiler. >+ * Check {@link #getDefaultOptions()} for a list of compliance values.</p> >+ * >+ * <p>The list of modified options is:</p> >+ * <ul> >+ * <li>{@link #COMPILER_CODEGEN_TARGET_PLATFORM}</li> >+ * <li>{@link #COMPILER_SOURCE}</li> >+ * <li>{@link #COMPILER_COMPLIANCE}</li> >+ * <li>{@link #COMPILER_PB_ASSERT_IDENTIFIER}</li> >+ * <li>{@link #COMPILER_PB_ENUM_IDENTIFIER}</li> >+ * </ul> >+ * >+ * <p>If the given compliance is unknown, the given map is unmodified.</p> >+ * >+ * @param compliance the given compliance >+ * @param options the given options map >+ */ >+ public static void setCompilanceOptions(String compliance, Map options) { >+ switch((int) (CompilerOptions.versionToJdkLevel(compliance) >>> 16)) { >+ case ClassFileConstants.MAJOR_VERSION_1_3: >+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3); >+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); >+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1); >+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE); >+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE); >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_4: >+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); >+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); >+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); >+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING); >+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING); >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_5: >+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); >+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); >+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); >+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); >+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_6: >+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6); >+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6); >+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6); >+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); >+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_7: >+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); >+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); >+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7); >+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); >+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); >+ } >+ } >+ >+ /** >+ * Sets the current table of options. All and only the options explicitly >+ * included in the given table are remembered; all previous option settings >+ * are forgotten, including ones not explicitly mentioned. >+ * <p> >+ * For a complete description of the configurable options, see >+ * <code>getDefaultOptions</code>. > * </p> > * >- * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>), >- * or <code>null</code> to reset all options to their default values >+ * @param newOptions >+ * the new options (key type: <code>String</code>; value type: >+ * <code>String</code>), or <code>null</code> to reset all >+ * options to their default values > * @see JavaCore#getDefaultOptions() > * @see JavaCorePreferenceInitializer for changing default settings > */ >Index: buildnotes_jdt-core.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v >retrieving revision 1.5582 >diff -u -r1.5582 buildnotes_jdt-core.html >--- buildnotes_jdt-core.html 27 Nov 2006 16:34:11 -0000 1.5582 >+++ buildnotes_jdt-core.html 27 Nov 2006 19:26:36 -0000 >@@ -51,6 +51,11 @@ > (<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_725">cvs</a>). > <h2>What's new in this drop</h2> > <ul> >+<li>Added <code>org.eclipse.jdt.core.JavaCore#VERSION_1_7</code>. It can be used to set the compliance, the source or the >+target platform values. This has no impact right now beside setting the major version inside .class file to >+<code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants#MAJOR_VERSION_1_7</code>.</li> >+<li>Added new API <code>org.eclipse.jdt.core.JavaCore#setCompilanceOptions(String, Map)</code> to set the compiler's >+options relative to a given compiler's compliance.</li> > <li>Tuned compiler semantics for unchecked cast detection. As a consequence, more warnings should be issued > (also see bugs <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=106451">106451</a> and > <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=165143">165143</a>). </li>
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 165954
: 54573