当前位置: 首页>>代码示例>>Java>>正文


Java ClassFileConstants.JDK1_2属性代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_2属性的典型用法代码示例。如果您正苦于以下问题:Java ClassFileConstants.JDK1_2属性的具体用法?Java ClassFileConstants.JDK1_2怎么用?Java ClassFileConstants.JDK1_2使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants的用法示例。


在下文中一共展示了ClassFileConstants.JDK1_2属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConstantPoolDeclaringClass

/**
 * Returns the type that should be substituted to original binding declaring class as the proper receiver type
 * @param currentScope
 * @param codegenBinding
 * @param actualReceiverType
 * @param isImplicitThisReceiver
 * @return the receiver type to use in constant pool
 */
public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, FieldBinding codegenBinding, TypeBinding actualReceiverType, boolean isImplicitThisReceiver) {
	ReferenceBinding constantPoolDeclaringClass = codegenBinding.declaringClass;
	// if the binding declaring class is not visible, need special action
	// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
	// NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
	// and not from Object or implicit static field access.
	if (TypeBinding.notEquals(constantPoolDeclaringClass, actualReceiverType.erasure())
			&& !actualReceiverType.isArrayType()
			&& constantPoolDeclaringClass != null // array.length
			&& codegenBinding.constant() == Constant.NotAConstant) {
		CompilerOptions options = currentScope.compilerOptions();
		if ((options.targetJDK >= ClassFileConstants.JDK1_2
					&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(isImplicitThisReceiver && codegenBinding.isStatic()))
					&& constantPoolDeclaringClass.id != TypeIds.T_JavaLangObject) // no change for Object fields
				|| !constantPoolDeclaringClass.canBeSeenBy(currentScope)) {

			return actualReceiverType.erasure();
		}
	}	
	return constantPoolDeclaringClass;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:CodeStream.java

示例2: getConstantPoolDeclaringClass

/**
 * Returns the type that should be substituted to original binding declaring class as the proper receiver type
 * @param currentScope
 * @param codegenBinding
 * @param actualReceiverType
 * @param isImplicitThisReceiver
 * @return the receiver type to use in constant pool
 */
public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, FieldBinding codegenBinding, TypeBinding actualReceiverType, boolean isImplicitThisReceiver) {
	ReferenceBinding constantPoolDeclaringClass = codegenBinding.declaringClass;
	// if the binding declaring class is not visible, need special action
	// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
	// NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
	// and not from Object or implicit static field access.
	if (constantPoolDeclaringClass != actualReceiverType.erasure()
			&& !actualReceiverType.isArrayType()
			&& constantPoolDeclaringClass != null // array.length
			&& codegenBinding.constant() == Constant.NotAConstant) {
		CompilerOptions options = currentScope.compilerOptions();
		if ((options.targetJDK >= ClassFileConstants.JDK1_2
					&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(isImplicitThisReceiver && codegenBinding.isStatic()))
					&& constantPoolDeclaringClass.id != TypeIds.T_JavaLangObject) // no change for Object fields
				|| !constantPoolDeclaringClass.canBeSeenBy(currentScope)) {

			return actualReceiverType.erasure();
		}
	}	
	return constantPoolDeclaringClass;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:29,代码来源:CodeStream.java

示例3: 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
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:CompilerOptions.java

示例4: versionToJdkLevel

public static long versionToJdkLevel(Object versionID) {
	if (versionID instanceof String) {
		String version = (String) versionID;
		// verification is optimized for all versions with same length and same "1." prefix
		if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
			switch (version.charAt(2)) {
				case '1':
					return ClassFileConstants.JDK1_1;
				case '2':
					return ClassFileConstants.JDK1_2;
				case '3':
					return ClassFileConstants.JDK1_3;
				case '4':
					return ClassFileConstants.JDK1_4;
				case '5':
					return ClassFileConstants.JDK1_5;
				case '6':
					return ClassFileConstants.JDK1_6;
				case '7':
					return ClassFileConstants.JDK1_7;
				case '8':
					return ClassFileConstants.JDK1_8;
				default:
					return 0; // unknown
			}
		}
		if (VERSION_JSR14.equals(versionID)) {
			return ClassFileConstants.JDK1_4;
		}
		if (VERSION_CLDC1_1.equals(versionID)) {
			return ClassFileConstants.CLDC_1_1;
		}
	}
	return 0; // unknown
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:CompilerOptions.java

示例5: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:55,代码来源:Main.java

示例6: 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
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:33,代码来源:CompilerOptions.java

示例7: versionToJdkLevel

public static long versionToJdkLevel(Object versionID) {
	if (versionID instanceof String) {
		String version = (String) versionID;
		// verification is optimized for all versions with same length and same "1." prefix
		if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
			switch (version.charAt(2)) {
				case '1':
					return ClassFileConstants.JDK1_1;
				case '2':
					return ClassFileConstants.JDK1_2;
				case '3':
					return ClassFileConstants.JDK1_3;
				case '4':
					return ClassFileConstants.JDK1_4;
				case '5':
					return ClassFileConstants.JDK1_5;
				case '6':
					return ClassFileConstants.JDK1_6;
				case '7':
					return ClassFileConstants.JDK1_7;
				default:
					return 0; // unknown
			}
		}
		if (VERSION_JSR14.equals(versionID)) {
			return ClassFileConstants.JDK1_4;
		}
		if (VERSION_CLDC1_1.equals(versionID)) {
			return ClassFileConstants.CLDC_1_1;
		}
	}
	return 0; // unknown
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:33,代码来源:CompilerOptions.java

示例8: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:57,代码来源:Main.java


注:本文中的org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_2属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。