本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_3属性的典型用法代码示例。如果您正苦于以下问题:Java ClassFileConstants.JDK1_3属性的具体用法?Java ClassFileConstants.JDK1_3怎么用?Java ClassFileConstants.JDK1_3使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
的用法示例。
在下文中一共展示了ClassFileConstants.JDK1_3属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ASTConverter
public ASTConverter(Map options, boolean resolveBindings, IProgressMonitor monitor) {
this.resolveBindings = resolveBindings;
this.referenceContext = null;
Object sourceModeSetting = options.get(JavaCore.COMPILER_SOURCE);
long sourceLevel = CompilerOptions.versionToJdkLevel(sourceModeSetting);
if (sourceLevel == 0) {
// unknown sourceModeSetting
sourceLevel = ClassFileConstants.JDK1_3;
}
this.scanner = new Scanner(
true /*comment*/,
false /*whitespace*/,
false /*nls*/,
sourceLevel /*sourceLevel*/,
null /*taskTags*/,
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
this.monitor = monitor;
this.insideComments = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_DOC_COMMENT_SUPPORT));
}
示例2: AbstractCommentParser
protected AbstractCommentParser(Parser sourceParser) {
this.sourceParser = sourceParser;
this.scanner = new Scanner(false, false, false, ClassFileConstants.JDK1_3, null, null, true/*taskCaseSensitive*/);
this.identifierStack = new char[20][];
this.identifierPositionStack = new long[20];
this.identifierLengthStack = new int[10];
this.astStack = new Object[30];
this.astLengthStack = new int[20];
this.reportProblems = sourceParser != null;
if (sourceParser != null) {
this.checkDocComment = this.sourceParser.options.docCommentSupport;
this.sourceLevel = this.sourceParser.options.sourceLevel;
this.scanner.sourceLevel = this.sourceLevel;
this.complianceLevel = this.sourceParser.options.complianceLevel;
}
}
示例3: DocCommentParser
DocCommentParser(AST ast, Scanner scanner, boolean check) {
super(null);
this.ast = ast;
this.scanner = scanner;
switch(this.ast.apiLevel()) {
case AST.JLS2_INTERNAL :
this.sourceLevel = ClassFileConstants.JDK1_3;
break;
case AST.JLS3_INTERNAL:
this.sourceLevel = ClassFileConstants.JDK1_5;
break;
default:
// AST.JLS4 for now
this.sourceLevel = ClassFileConstants.JDK1_7;
}
this.checkDocComment = check;
this.kind = DOM_PARSER | TEXT_PARSE;
}
示例4: ASTConverter
public ASTConverter(Map options, boolean resolveBindings, IProgressMonitor monitor) {
this.resolveBindings = resolveBindings;
Object sourceModeSetting = options.get(JavaCore.COMPILER_SOURCE);
long sourceLevel = CompilerOptions.versionToJdkLevel(sourceModeSetting);
if (sourceLevel == 0) {
// unknown sourceModeSetting
sourceLevel = ClassFileConstants.JDK1_3;
}
this.scanner = new Scanner(
true /*comment*/,
false /*whitespace*/,
false /*nls*/,
sourceLevel /*sourceLevel*/,
null /*taskTags*/,
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
this.monitor = monitor;
this.insideComments = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_DOC_COMMENT_SUPPORT));
}
示例5: AST
/**
* Creates a new Java abstract syntax tree
* (AST) following the specified set of API rules.
*
* @param level the API level; one of the <code>JLS*</code> level constants
* @since 3.0
*/
private AST(int level) {
switch(level) {
case JLS2_INTERNAL :
case JLS3_INTERNAL :
this.apiLevel = level;
// initialize a scanner
this.scanner = new Scanner(
true /*comment*/,
true /*whitespace*/,
false /*nls*/,
ClassFileConstants.JDK1_3 /*sourceLevel*/,
ClassFileConstants.JDK1_5 /*complianceLevel*/,
null/*taskTag*/,
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
break;
case JLS4 :
this.apiLevel = level;
// initialize a scanner
this.scanner = new Scanner(
true /*comment*/,
true /*whitespace*/,
false /*nls*/,
ClassFileConstants.JDK1_7 /*sourceLevel*/,
ClassFileConstants.JDK1_7 /*complianceLevel*/,
null/*taskTag*/,
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
break;
default:
throw new IllegalArgumentException("Unsupported JLS level"); //$NON-NLS-1$
}
}
示例6: CodeFormatterVisitor
public CodeFormatterVisitor(DefaultCodeFormatterOptions preferences, Map settings, IRegion[] regions, CodeSnippetParsingUtil codeSnippetParsingUtil, boolean includeComments) {
long sourceLevel = settings == null
? ClassFileConstants.JDK1_3
: CompilerOptions.versionToJdkLevel(settings.get(JavaCore.COMPILER_SOURCE));
this.localScanner = new Scanner(true, false, false/*nls*/, sourceLevel/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
this.preferences = preferences;
this.scribe = new Scribe(this, sourceLevel, regions, codeSnippetParsingUtil, includeComments);
}
示例7: 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;
}
示例8: setIdentifier
/**
* Sets the identifier of this node to the given value.
* The identifier should be legal according to the rules
* of the Java language. Note that keywords are not legal
* identifiers.
* <p>
* Note that the list of keywords may depend on the version of the
* language (determined when the AST object was created).
* </p>
*
* @param identifier the identifier of this node
* @exception IllegalArgumentException if the identifier is invalid
*/
public void setIdentifier(String identifier) {
// update internalSetIdentifier if this is changed
if (identifier == null) {
throw new IllegalArgumentException();
}
Scanner scanner = this.ast.scanner;
long sourceLevel = scanner.sourceLevel;
long complianceLevel = scanner.complianceLevel;
try {
scanner.sourceLevel = ClassFileConstants.JDK1_3;
scanner.complianceLevel = ClassFileConstants.JDK1_5;
char[] source = identifier.toCharArray();
scanner.setSource(source);
final int length = source.length;
scanner.resetTo(0, length - 1);
try {
int tokenType = scanner.scanIdentifier();
if (tokenType != TerminalTokens.TokenNameIdentifier) {
throw new IllegalArgumentException("Invalid identifier : >" + identifier + "<"); //$NON-NLS-1$//$NON-NLS-2$
}
if (scanner.currentPosition != length) {
// this is the case when there is only one identifier see 87849
throw new IllegalArgumentException("Invalid identifier : >" + identifier + "<"); //$NON-NLS-1$//$NON-NLS-2$
}
} catch (InvalidInputException e) {
IllegalArgumentException iae = new IllegalArgumentException("Invalid identifier : >" + identifier + "<"); //$NON-NLS-1$//$NON-NLS-2$
iae.initCause(e);
throw iae;
}
} finally {
this.ast.scanner.sourceLevel = sourceLevel;
this.ast.scanner.complianceLevel = complianceLevel;
}
preValueChange(IDENTIFIER_PROPERTY);
this.identifier = identifier;
postValueChange(IDENTIFIER_PROPERTY);
}
示例9: AST
/**
* Creates a new, empty abstract syntax tree using the given options.
* <p>
* Following option keys are significant:
* <ul>
* <li><code>"org.eclipse.jdt.core.compiler.source"</code> -
* indicates source compatibility mode (as per <code>JavaCore</code>);
* <code>"1.3"</code> means the source code is as per JDK 1.3;
* <code>"1.4"</code> means the source code is as per JDK 1.4
* (<code>"assert"</code> is now a keyword);
* <code>"1.5"</code> means the source code is as per JDK 1.5
* (<code>"enum"</code> is now a keyword);
* <code>"1.7"</code> means the source code is as per JDK 1.7;
* additional legal values may be added later. </li>
* </ul>
* Options other than the above are ignored.
* </p>
*
* @param options the table of options (key type: <code>String</code>;
* value type: <code>String</code>)
* @see JavaCore#getDefaultOptions()
* @deprecated Clients should port their code to use the new JLS4 AST API and call
* {@link #newAST(int) AST.newAST(AST.JLS4)} instead of using this constructor.
*/
public AST(Map options) {
this(JLS2);
Object sourceLevelOption = options.get(JavaCore.COMPILER_SOURCE);
long sourceLevel = ClassFileConstants.JDK1_3;
if (JavaCore.VERSION_1_4.equals(sourceLevelOption)) {
sourceLevel = ClassFileConstants.JDK1_4;
} else if (JavaCore.VERSION_1_5.equals(sourceLevelOption)) {
sourceLevel = ClassFileConstants.JDK1_5;
} else if (JavaCore.VERSION_1_7.equals(sourceLevelOption)) {
sourceLevel = ClassFileConstants.JDK1_7;
}
Object complianceLevelOption = options.get(JavaCore.COMPILER_COMPLIANCE);
long complianceLevel = ClassFileConstants.JDK1_3;
if (JavaCore.VERSION_1_4.equals(complianceLevelOption)) {
complianceLevel = ClassFileConstants.JDK1_4;
} else if (JavaCore.VERSION_1_5.equals(complianceLevelOption)) {
complianceLevel = ClassFileConstants.JDK1_5;
} else if (JavaCore.VERSION_1_7.equals(complianceLevelOption)) {
complianceLevel = ClassFileConstants.JDK1_7;
}
// override scanner if 1.4 or 1.5 asked for
this.scanner = new Scanner(
true /*comment*/,
true /*whitespace*/,
false /*nls*/,
sourceLevel /*sourceLevel*/,
complianceLevel /*complianceLevel*/,
null/*taskTag*/,
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
}
示例10: resolve
public void resolve(BlockScope scope) {
this.exceptionType = this.exception.resolveType(scope);
recordExceptionsForEnclosingLambda(scope, this.exceptionType);
if (this.exceptionType != null && this.exceptionType.isValidBinding()) {
if (this.exceptionType == TypeBinding.NULL) {
if (scope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_3){
// if compliant with 1.4, this problem will not be reported
scope.problemReporter().cannotThrowNull(this.exception);
}
} else if (this.exceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null) {
scope.problemReporter().cannotThrowType(this.exception, this.exceptionType);
}
this.exception.computeConversion(scope, this.exceptionType, this.exceptionType);
}
}
示例11: 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
}
示例12: PublicScanner
public PublicScanner() {
this(false /*comment*/, false /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3 /*sourceLevel*/, null/*taskTag*/, null/*taskPriorities*/, true /*taskCaseSensitive*/);
}
示例13: createScanner
/**
* Create a scanner, indicating the level of detail requested for tokenizing. The scanner can then be
* used to tokenize some source in a Java aware way.
* Here is a typical scanning loop:
*
* <code>
* <pre>
* IScanner scanner = ToolFactory.createScanner(false, false, false, false);
* scanner.setSource("int i = 0;".toCharArray());
* while (true) {
* int token = scanner.getNextToken();
* if (token == ITerminalSymbols.TokenNameEOF) break;
* System.out.println(token + " : " + new String(scanner.getCurrentTokenSource()));
* }
* </pre>
* </code>
*
* <p>By default the compliance used to create the scanner is the workspace's compliance when running inside the IDE
* or 1.4 if running from outside of a headless eclipse.
* </p>
*
* @param tokenizeComments if set to <code>false</code>, comments will be silently consumed
* @param tokenizeWhiteSpace if set to <code>false</code>, white spaces will be silently consumed,
* @param assertMode if set to <code>false</code>, occurrences of 'assert' will be reported as identifiers
* ({@link ITerminalSymbols#TokenNameIdentifier}), whereas if set to <code>true</code>, it
* would report assert keywords ({@link ITerminalSymbols#TokenNameassert}). Java 1.4 has introduced
* a new 'assert' keyword.
* @param recordLineSeparator if set to <code>true</code>, the scanner will record positions of encountered line
* separator ends. In case of multi-character line separators, the last character position is considered. These positions
* can then be extracted using {@link IScanner#getLineEnds()}. Only non-unicode escape sequences are
* considered as valid line separators.
* @return a scanner
* @see org.eclipse.jdt.core.compiler.IScanner
* @see #createScanner(boolean, boolean, boolean, String, String)
*/
public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator){
// use default workspace compliance
long complianceLevelValue = CompilerOptions.versionToJdkLevel(JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE));
if (complianceLevelValue == 0) complianceLevelValue = ClassFileConstants.JDK1_4; // fault-tolerance
PublicScanner scanner =
new PublicScanner(
tokenizeComments,
tokenizeWhiteSpace,
false/*nls*/,
assertMode ? ClassFileConstants.JDK1_4 : ClassFileConstants.JDK1_3/*sourceLevel*/,
complianceLevelValue,
null/*taskTags*/,
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
scanner.recordLineSeparator = recordLineSeparator;
return scanner;
}
示例14: 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 ClassFileConstants.MAJOR_VERSION_1_1 : // 1.0 and 1.1
return ClassFileConstants.JDK1_1 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_1_2 : // 1.2
return ClassFileConstants.JDK1_2 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_1_3 : // 1.3
return ClassFileConstants.JDK1_3 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_1_4 : // 1.4
return ClassFileConstants.JDK1_4 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_1_5 : // 1.5
return ClassFileConstants.JDK1_5 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_1_6 : // 1.6
return ClassFileConstants.JDK1_6 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_1_7 : // 1.7
return ClassFileConstants.JDK1_7 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_1_8: // 1.8
return ClassFileConstants.JDK1_8 >= minimalSupportedVersion;
}
// unknown version
return false;
}
示例15: generateSyntheticEnclosingInstanceValues
/**
* Code responsible to generate the suitable code to supply values for the synthetic enclosing
* instance arguments of a constructor invocation of a nested type.
*/
public void generateSyntheticEnclosingInstanceValues(BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, ASTNode invocationSite) {
// supplying enclosing instance for the anonymous type's superclass
ReferenceBinding checkedTargetType = targetType.isAnonymousType() ? (ReferenceBinding)targetType.superclass().erasure() : targetType;
boolean hasExtraEnclosingInstance = enclosingInstance != null;
if (hasExtraEnclosingInstance
&& (!checkedTargetType.isNestedType() || checkedTargetType.isStatic())) {
currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
return;
}
// perform some emulation work in case there is some and we are inside a local type only
ReferenceBinding[] syntheticArgumentTypes;
if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes()) != null) {
ReferenceBinding targetEnclosingType = checkedTargetType.enclosingType();
long compliance = currentScope.compilerOptions().complianceLevel;
// deny access to enclosing instance argument for allocation and super constructor call (if 1.4)
// always consider it if complying to 1.5
boolean denyEnclosingArgInConstructorCall;
if (compliance <= ClassFileConstants.JDK1_3) {
denyEnclosingArgInConstructorCall = invocationSite instanceof AllocationExpression;
} else if (compliance == ClassFileConstants.JDK1_4){
denyEnclosingArgInConstructorCall = invocationSite instanceof AllocationExpression
|| invocationSite instanceof ExplicitConstructorCall && ((ExplicitConstructorCall)invocationSite).isSuperAccess();
} else {
//compliance >= JDK1_5
denyEnclosingArgInConstructorCall = (invocationSite instanceof AllocationExpression
|| invocationSite instanceof ExplicitConstructorCall && ((ExplicitConstructorCall)invocationSite).isSuperAccess())
&& !targetType.isLocalType();
}
boolean complyTo14 = compliance >= ClassFileConstants.JDK1_4;
for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
ReferenceBinding syntheticArgType = syntheticArgumentTypes[i];
if (hasExtraEnclosingInstance && TypeBinding.equalsEquals(syntheticArgType, targetEnclosingType)) {
hasExtraEnclosingInstance = false;
enclosingInstance.generateCode(currentScope, this, true);
if (complyTo14){
dup();
invokeObjectGetClass(); // will perform null check
pop();
}
} else {
Object[] emulationPath = currentScope.getEmulationPath(
syntheticArgType,
false /*not only exact match (that is, allow compatible)*/,
denyEnclosingArgInConstructorCall);
generateOuterAccess(emulationPath, invocationSite, syntheticArgType, currentScope);
}
}
if (hasExtraEnclosingInstance){
currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
}
}
}