本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_6属性的典型用法代码示例。如果您正苦于以下问题:Java ClassFileConstants.JDK1_6属性的具体用法?Java ClassFileConstants.JDK1_6怎么用?Java ClassFileConstants.JDK1_6使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
的用法示例。
在下文中一共展示了ClassFileConstants.JDK1_6属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toClassFmt
private long toClassFmt(final JavaVersion version) {
if (version != null) {
switch (version) {
case JAVA5:
return ClassFileConstants.JDK1_5;
case JAVA6:
return ClassFileConstants.JDK1_6;
case JAVA7:
return ClassFileConstants.JDK1_7;
case JAVA8:
return (((ClassFileConstants.MAJOR_VERSION_1_7 + 1) << 16) + ClassFileConstants.MINOR_VERSION_0);
case JAVA9:
return (((ClassFileConstants.MAJOR_VERSION_1_7 + 2) << 16) + ClassFileConstants.MINOR_VERSION_0);
default:
break;
}
}
return 0;
}
示例2: getLatestEcjCompilerVersionConstant
public static long getLatestEcjCompilerVersionConstant() {
if (latestEcjCompilerVersionConstantCached != 0) return latestEcjCompilerVersionConstantCached;
int highestVersionSoFar = 0;
for (Field f : ClassFileConstants.class.getDeclaredFields()) {
try {
if (f.getName().startsWith("JDK1_")) {
int thisVersion = Integer.parseInt(f.getName().substring("JDK1_".length()));
if (thisVersion > highestVersionSoFar) {
highestVersionSoFar = thisVersion;
latestEcjCompilerVersionConstantCached = (Long) f.get(null);
}
}
} catch (Exception ignore) {}
}
if (highestVersionSoFar > 6 && !ecjSupportsJava7Features()) {
latestEcjCompilerVersionConstantCached = ClassFileConstants.JDK1_6;
}
return latestEcjCompilerVersionConstantCached;
}
示例3: parse
Javadoc parse(String rawInput, int from, int to) {
char[] rawContent;
rawContent = new char[to + GENERIC_JAVA_CLASS_SUFFIX.length];
Arrays.fill(rawContent, 0, from, ' ');
System.arraycopy(rawInput.substring(from, to).toCharArray(), 0, rawContent, from, to - from);
// Eclipse crashes if there's no character following the javadoc.
System.arraycopy(GENERIC_JAVA_CLASS_SUFFIX, 0, rawContent, to, GENERIC_JAVA_CLASS_SUFFIX.length);
this.sourceLevel = ClassFileConstants.JDK1_6;
this.scanner.setSource(rawContent);
this.source = rawContent;
this.javadocStart = from;
this.javadocEnd = to;
this.reportProblems = true;
this.docComment = new Javadoc(this.javadocStart, this.javadocEnd);
commentParse();
this.docComment.valuePositions = -1;
this.docComment.sourceEnd--;
return docComment;
}
示例4: ClassFile
public ClassFile(SourceTypeBinding typeBinding) {
// default constructor for subclasses
this.constantPool = new ConstantPool(this);
final CompilerOptions options = typeBinding.scope.compilerOptions();
this.targetJDK = options.targetJDK;
this.produceAttributes = options.produceDebugAttributes;
this.referenceBinding = typeBinding;
this.isNestedType = typeBinding.isNestedType();
if (this.targetJDK >= ClassFileConstants.JDK1_6) {
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
this.codeStream = new StackMapFrameCodeStream(this);
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
this.codeStream = new StackMapFrameCodeStream(this);
} else {
this.codeStream = new CodeStream(this);
}
initByteArrays();
}
示例5: ecjCompilerOptions
protected CompilerOptions ecjCompilerOptions() {
CompilerOptions options = new CompilerOptions();
options.complianceLevel = ClassFileConstants.JDK1_6;
options.sourceLevel = ClassFileConstants.JDK1_6;
options.targetJDK = ClassFileConstants.JDK1_6;
options.parseLiteralExpressionsAsConstants = true;
return options;
}
示例6: getDefaultBootclasspath
Iterable<? extends File> getDefaultBootclasspath() {
ArrayList<File> files = new ArrayList<File>();
String javaversion = System.getProperty("java.version");//$NON-NLS-1$
if(javaversion.length() > 3)
javaversion = javaversion.substring(0, 3);
long jdkLevel = CompilerOptions.versionToJdkLevel(javaversion);
if (jdkLevel < ClassFileConstants.JDK1_6) {
// wrong jdk - 1.6 or above is required
return null;
}
/*
* Handle >= JDK 1.6
*/
String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
File javaHomeFile = null;
if (javaHome != null) {
javaHomeFile = new File(javaHome);
if (!javaHomeFile.exists())
javaHomeFile = null;
}
addFilesFrom(javaHomeFile, "java.endorsed.dirs", "/lib/endorsed", files);//$NON-NLS-1$//$NON-NLS-2$
if (javaHomeFile != null) {
File[] directoriesToCheck = null;
if (System.getProperty("os.name").startsWith("Mac")) {//$NON-NLS-1$//$NON-NLS-2$
directoriesToCheck = new File[] { new File(javaHomeFile, "../Classes"), //$NON-NLS-1$
};
} else {
directoriesToCheck = new File[] { new File(javaHomeFile, "lib") //$NON-NLS-1$
};
}
File[][] jars = Main.getLibrariesFiles(directoriesToCheck);
addFiles(jars, files);
}
addFilesFrom(javaHomeFile, "java.ext.dirs", "/lib/ext", files);//$NON-NLS-1$//$NON-NLS-2$
return files;
}
示例7: getSourceVersion
@Override
public SourceVersion getSourceVersion() {
if (this._compiler.options.sourceLevel <= ClassFileConstants.JDK1_5) {
return SourceVersion.RELEASE_5;
}
if (this._compiler.options.sourceLevel == ClassFileConstants.JDK1_6) {
return SourceVersion.RELEASE_6;
}
try {
return SourceVersion.valueOf("RELEASE_7"); //$NON-NLS-1$
} catch(IllegalArgumentException e) {
// handle call on a JDK 6
return SourceVersion.RELEASE_6;
}
}
示例8: ClassFile
public ClassFile(SourceTypeBinding typeBinding) {
// default constructor for subclasses
this.constantPool = new ConstantPool(this);
final CompilerOptions options = typeBinding.scope.compilerOptions();
this.targetJDK = options.targetJDK;
this.produceAttributes = options.produceDebugAttributes;
this.referenceBinding = typeBinding;
this.isNestedType = typeBinding.isNestedType();
if (this.targetJDK >= ClassFileConstants.JDK1_6) {
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
if (this.targetJDK >= ClassFileConstants.JDK1_8) {
this.produceAttributes |= ClassFileConstants.ATTR_TYPE_ANNOTATION;
this.codeStream = new TypeAnnotationCodeStream(this);
if (options.produceMethodParameters) {
this.produceAttributes |= ClassFileConstants.ATTR_METHOD_PARAMETERS;
}
} else {
this.codeStream = new StackMapFrameCodeStream(this);
}
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
this.codeStream = new StackMapFrameCodeStream(this);
} else {
this.codeStream = new CodeStream(this);
}
initByteArrays();
}
示例9: reset
public void reset(SourceTypeBinding typeBinding) {
// the code stream is reinitialized for each method
final CompilerOptions options = typeBinding.scope.compilerOptions();
this.referenceBinding = typeBinding;
this.isNestedType = typeBinding.isNestedType();
this.targetJDK = options.targetJDK;
this.produceAttributes = options.produceDebugAttributes;
if (this.targetJDK >= ClassFileConstants.JDK1_6) {
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
if (this.targetJDK >= ClassFileConstants.JDK1_8) {
this.produceAttributes |= ClassFileConstants.ATTR_TYPE_ANNOTATION;
if (options.produceMethodParameters) {
this.produceAttributes |= ClassFileConstants.ATTR_METHOD_PARAMETERS;
}
}
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
}
this.bytes = null;
this.constantPool.reset();
this.codeStream.reset(this);
this.constantPoolOffset = 0;
this.contentsOffset = 0;
this.creatingProblemType = false;
this.enclosingClassFile = null;
this.headerOffset = 0;
this.methodCount = 0;
this.methodCountOffset = 0;
if (this.innerClassesBindings != null) {
this.innerClassesBindings.clear();
}
if (this.bootstrapMethods != null) {
this.bootstrapMethods.clear();
}
this.missingTypes = null;
this.visitedTypes = null;
}
示例10: buildFileForCompliance
private static void buildFileForCompliance(
String file,
int length,
String[] tokens) {
byte[] result = new byte[length * 8];
for (int i = 0; i < tokens.length; i = i + 3) {
if("2".equals(tokens[i])) { //$NON-NLS-1$
int index = Integer.parseInt(tokens[i + 1]);
String token = tokens[i + 2].trim();
long compliance = 0;
if("1.4".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK1_4;
} else if("1.5".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK1_5;
} else if("1.6".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK1_6;
} else if("1.7".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK1_7;
} else if("1.8".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK1_8;
} else if("recovery".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK_DEFERRED;
}
int j = index * 8;
result[j] = (byte)(compliance >>> 56);
result[j + 1] = (byte)(compliance >>> 48);
result[j + 2] = (byte)(compliance >>> 40);
result[j + 3] = (byte)(compliance >>> 32);
result[j + 4] = (byte)(compliance >>> 24);
result[j + 5] = (byte)(compliance >>> 16);
result[j + 6] = (byte)(compliance >>> 8);
result[j + 7] = (byte)(compliance);
}
}
buildFileForTable(file, result);
}
示例11: detectNameClash
boolean detectNameClash(MethodBinding current, MethodBinding inherited, boolean treatAsSynthetic) {
MethodBinding methodToCheck = inherited;
MethodBinding original = methodToCheck.original(); // can be the same as inherited
if (!current.areParameterErasuresEqual(original))
return false;
int severity = ProblemSeverities.Error;
if (this.environment.globalOptions.complianceLevel == ClassFileConstants.JDK1_6) {
// for 1.6 return types also need to be checked
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719
if (TypeBinding.notEquals(current.returnType.erasure(), original.returnType.erasure()))
severity = ProblemSeverities.Warning;
}
if (!treatAsSynthetic) {
// For a user method, see if current class overrides the inherited method. If it does,
// then any grievance we may have ought to be against the current class's method and
// NOT against any super implementations. https://bugs.eclipse.org/bugs/show_bug.cgi?id=293615
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=315978 : we now defer this rather expensive
// check to just before reporting (the incorrect) name clash. In the event there is no name
// clash to report to begin with (the common case), no penalty needs to be paid.
MethodBinding[] currentNamesakes = (MethodBinding[]) this.currentMethods.get(inherited.selector);
if (currentNamesakes.length > 1) { // we know it ought to at least one and that current is NOT the override
for (int i = 0, length = currentNamesakes.length; i < length; i++) {
MethodBinding currentMethod = currentNamesakes[i];
if (currentMethod != current && doesMethodOverride(currentMethod, inherited)) {
methodToCheck = currentMethod;
break;
}
}
}
}
original = methodToCheck.original(); // can be the same as inherited
if (!current.areParameterErasuresEqual(original))
return false;
original = inherited.original(); // For error reporting use, inherited.original()
problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original, severity);
if (severity == ProblemSeverities.Warning) return false;
return true;
}
示例12: versionFromJdkLevel
public static String versionFromJdkLevel(long jdkLevel) {
switch ((int)(jdkLevel>>16)) {
case ClassFileConstants.MAJOR_VERSION_1_1 :
if (jdkLevel == ClassFileConstants.JDK1_1)
return VERSION_1_1;
break;
case ClassFileConstants.MAJOR_VERSION_1_2 :
if (jdkLevel == ClassFileConstants.JDK1_2)
return VERSION_1_2;
break;
case ClassFileConstants.MAJOR_VERSION_1_3 :
if (jdkLevel == ClassFileConstants.JDK1_3)
return VERSION_1_3;
break;
case ClassFileConstants.MAJOR_VERSION_1_4 :
if (jdkLevel == ClassFileConstants.JDK1_4)
return VERSION_1_4;
break;
case ClassFileConstants.MAJOR_VERSION_1_5 :
if (jdkLevel == ClassFileConstants.JDK1_5)
return VERSION_1_5;
break;
case ClassFileConstants.MAJOR_VERSION_1_6 :
if (jdkLevel == ClassFileConstants.JDK1_6)
return VERSION_1_6;
break;
case ClassFileConstants.MAJOR_VERSION_1_7 :
if (jdkLevel == ClassFileConstants.JDK1_7)
return VERSION_1_7;
break;
case ClassFileConstants.MAJOR_VERSION_1_8 :
if (jdkLevel == ClassFileConstants.JDK1_8)
return VERSION_1_8;
break;
}
return Util.EMPTY_STRING; // unknown version
}
示例13: versionFromJdkLevel
public static String versionFromJdkLevel(long jdkLevel) {
switch ((int)(jdkLevel>>16)) {
case ClassFileConstants.MAJOR_VERSION_1_1 :
if (jdkLevel == ClassFileConstants.JDK1_1)
return VERSION_1_1;
break;
case ClassFileConstants.MAJOR_VERSION_1_2 :
if (jdkLevel == ClassFileConstants.JDK1_2)
return VERSION_1_2;
break;
case ClassFileConstants.MAJOR_VERSION_1_3 :
if (jdkLevel == ClassFileConstants.JDK1_3)
return VERSION_1_3;
break;
case ClassFileConstants.MAJOR_VERSION_1_4 :
if (jdkLevel == ClassFileConstants.JDK1_4)
return VERSION_1_4;
break;
case ClassFileConstants.MAJOR_VERSION_1_5 :
if (jdkLevel == ClassFileConstants.JDK1_5)
return VERSION_1_5;
break;
case ClassFileConstants.MAJOR_VERSION_1_6 :
if (jdkLevel == ClassFileConstants.JDK1_6)
return VERSION_1_6;
break;
case ClassFileConstants.MAJOR_VERSION_1_7 :
if (jdkLevel == ClassFileConstants.JDK1_7)
return VERSION_1_7;
break;
}
return Util.EMPTY_STRING; // unknown version
}
示例14: detectNameClash
boolean detectNameClash(MethodBinding current, MethodBinding inherited, boolean treatAsSynthetic) {
MethodBinding methodToCheck = inherited;
MethodBinding original = methodToCheck.original(); // can be the same as inherited
if (!current.areParameterErasuresEqual(original))
return false;
int severity = ProblemSeverities.Error;
if (this.environment.globalOptions.complianceLevel == ClassFileConstants.JDK1_6) {
// for 1.6 return types also need to be checked
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719
if (current.returnType.erasure() != original.returnType.erasure())
severity = ProblemSeverities.Warning;
}
if (!treatAsSynthetic) {
// For a user method, see if current class overrides the inherited method. If it does,
// then any grievance we may have ought to be against the current class's method and
// NOT against any super implementations. https://bugs.eclipse.org/bugs/show_bug.cgi?id=293615
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=315978 : we now defer this rather expensive
// check to just before reporting (the incorrect) name clash. In the event there is no name
// clash to report to begin with (the common case), no penalty needs to be paid.
MethodBinding[] currentNamesakes = (MethodBinding[]) this.currentMethods.get(inherited.selector);
if (currentNamesakes.length > 1) { // we know it ought to at least one and that current is NOT the override
for (int i = 0, length = currentNamesakes.length; i < length; i++) {
MethodBinding currentMethod = currentNamesakes[i];
if (currentMethod != current && doesMethodOverride(currentMethod, inherited)) {
methodToCheck = currentMethod;
break;
}
}
}
}
original = methodToCheck.original(); // can be the same as inherited
if (!current.areParameterErasuresEqual(original))
return false;
original = inherited.original(); // For error reporting use, inherited.original()
problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original, severity);
if (severity == ProblemSeverities.Warning) return false;
return true;
}
示例15: checkVMVersion
/**
* Return true if and only if the running VM supports the given minimal version.
*
* <p>This only checks the major version, since the minor version is always 0 (at least for the useful cases).</p>
* <p>The given minimalSupportedVersion is one of the constants:</p>
* <ul>
* <li><code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_1</code></li>
* <li><code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_2</code></li>
* <li><code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_3</code></li>
* <li><code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_4</code></li>
* <li><code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_5</code></li>
* <li><code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_6</code></li>
* <li><code>org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_7</code></li>
* </ul>
* @param minimalSupportedVersion the given minimal version
* @return true if and only if the running VM supports the given minimal version, false otherwise
*/
private boolean checkVMVersion(long minimalSupportedVersion) {
// the format of this property is supposed to be xx.x where x are digits.
String classFileVersion = System.getProperty("java.class.version"); //$NON-NLS-1$
if (classFileVersion == null) {
// by default we don't support a class file version we cannot recognize
return false;
}
int index = classFileVersion.indexOf('.');
if (index == -1) {
// by default we don't support a class file version we cannot recognize
return false;
}
int majorVersion;
try {
majorVersion = Integer.parseInt(classFileVersion.substring(0, index));
} catch (NumberFormatException e) {
// by default we don't support a class file version we cannot recognize
return false;
}
switch(majorVersion) {
case 45 : // 1.0 and 1.1
return ClassFileConstants.JDK1_1 >= minimalSupportedVersion;
case 46 : // 1.2
return ClassFileConstants.JDK1_2 >= minimalSupportedVersion;
case 47 : // 1.3
return ClassFileConstants.JDK1_3 >= minimalSupportedVersion;
case 48 : // 1.4
return ClassFileConstants.JDK1_4 >= minimalSupportedVersion;
case 49 : // 1.5
return ClassFileConstants.JDK1_5 >= minimalSupportedVersion;
case 50 : // 1.6
return ClassFileConstants.JDK1_6 >= minimalSupportedVersion;
case 51 : // 1.7
return ClassFileConstants.JDK1_7 >= minimalSupportedVersion;
}
// unknown version
return false;
}