本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.AccSynthetic方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFileConstants.AccSynthetic方法的具体用法?Java ClassFileConstants.AccSynthetic怎么用?Java ClassFileConstants.AccSynthetic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
的用法示例。
在下文中一共展示了ClassFileConstants.AccSynthetic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateMethodInfoHeader
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
/**
* INTERNAL USE-ONLY
* That method generates the header of a method info:
* The header consists in:
* - the access flags
* - the name index of the method name inside the constant pool
* - the descriptor index of the signature of the method inside the constant pool.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
* @param accessFlags the access flags
*/
public void generateMethodInfoHeader(MethodBinding methodBinding, int accessFlags) {
// check that there is enough space to write all the bytes for the method info corresponding
// to the @methodBinding
this.methodCount++; // add one more method
if (this.contentsOffset + 10 >= this.contents.length) {
resizeContents(10);
}
if (this.targetJDK < ClassFileConstants.JDK1_5) {
// pre 1.5, synthetic is an attribute, not a modifier
// pre 1.5, varargs is an attribute, not a modifier (-target jsr14 mode)
accessFlags &= ~(ClassFileConstants.AccSynthetic | ClassFileConstants.AccVarargs);
}
if ((methodBinding.tagBits & TagBits.ClearPrivateModifier) != 0) {
accessFlags &= ~ClassFileConstants.AccPrivate;
}
this.contents[this.contentsOffset++] = (byte) (accessFlags >> 8);
this.contents[this.contentsOffset++] = (byte) accessFlags;
int nameIndex = this.constantPool.literalIndex(methodBinding.selector);
this.contents[this.contentsOffset++] = (byte) (nameIndex >> 8);
this.contents[this.contentsOffset++] = (byte) nameIndex;
int descriptorIndex = this.constantPool.literalIndex(methodBinding.signature(this));
this.contents[this.contentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[this.contentsOffset++] = (byte) descriptorIndex;
}
示例2: SyntheticMethodBinding
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
/**
* Construct a bridge method
*/
public SyntheticMethodBinding(MethodBinding overridenMethodToBridge, MethodBinding targetMethod, SourceTypeBinding declaringClass) {
this.declaringClass = declaringClass;
this.selector = overridenMethodToBridge.selector;
// amongst other, clear the AccGenericSignature, so as to ensure no remains of original inherited persist (101794)
// also use the modifiers from the target method, as opposed to inherited one (147690)
this.modifiers = (targetMethod.modifiers | ClassFileConstants.AccBridge | ClassFileConstants.AccSynthetic) & ~(ClassFileConstants.AccSynchronized | ClassFileConstants.AccAbstract | ClassFileConstants.AccNative | ClassFileConstants.AccFinal | ExtraCompilerModifiers.AccGenericSignature);
this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
this.returnType = overridenMethodToBridge.returnType;
this.parameters = overridenMethodToBridge.parameters;
this.thrownExceptions = overridenMethodToBridge.thrownExceptions;
this.targetMethod = targetMethod;
this.purpose = SyntheticMethodBinding.BridgeMethod;
SyntheticMethodBinding[] knownAccessMethods = declaringClass.syntheticMethods();
int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
this.index = methodId;
}
示例3: addSyntheticFieldForClassLiteral
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public FieldBinding addSyntheticFieldForClassLiteral(TypeBinding targetType, BlockScope blockScope) {
if (this.synthetics == null)
this.synthetics = new HashMap[MAX_SYNTHETICS];
if (this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL] == null)
this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL] = new HashMap(5);
// use a different table than FIELDS, given there might be a collision between emulation of X.this$0 and X.class.
FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].get(targetType);
if (synthField == null) {
synthField = new SyntheticFieldBinding(
CharOperation.concat(
TypeConstants.SYNTHETIC_CLASS,
String.valueOf(this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].size()).toCharArray()),
blockScope.getJavaLangClass(),
ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic,
this,
Constant.NotAConstant,
this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].size());
this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].put(targetType, synthField);
}
// ensure there is not already such a field defined by the user
FieldBinding existingField;
if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
TypeDeclaration typeDecl = blockScope.referenceType();
FieldDeclaration[] typeDeclarationFields = typeDecl.fields;
int max = typeDeclarationFields == null ? 0 : typeDeclarationFields.length;
for (int i = 0; i < max; i++) {
FieldDeclaration fieldDecl = typeDeclarationFields[i];
if (fieldDecl.binding == existingField) {
blockScope.problemReporter().duplicateFieldInType(this, fieldDecl);
break;
}
}
}
return synthField;
}
示例4: addFieldInfo
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
/**
* INTERNAL USE-ONLY
* This methods generates the bytes for the given field binding
* @param fieldBinding the given field binding
*/
private void addFieldInfo(FieldBinding fieldBinding) {
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
if (this.contentsOffset + 8 >= this.contents.length) {
resizeContents(8);
}
// Now we can generate all entries into the byte array
// First the accessFlags
int accessFlags = fieldBinding.getAccessFlags();
if (this.targetJDK < ClassFileConstants.JDK1_5) {
// pre 1.5, synthetic was an attribute, not a modifier
accessFlags &= ~ClassFileConstants.AccSynthetic;
}
this.contents[this.contentsOffset++] = (byte) (accessFlags >> 8);
this.contents[this.contentsOffset++] = (byte) accessFlags;
// Then the nameIndex
int nameIndex = this.constantPool.literalIndex(fieldBinding.name);
this.contents[this.contentsOffset++] = (byte) (nameIndex >> 8);
this.contents[this.contentsOffset++] = (byte) nameIndex;
// Then the descriptorIndex
int descriptorIndex = this.constantPool.literalIndex(fieldBinding.type);
this.contents[this.contentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[this.contentsOffset++] = (byte) descriptorIndex;
int fieldAttributeOffset = this.contentsOffset;
int attributeNumber = 0;
// leave some space for the number of attributes
this.contentsOffset += 2;
attributeNumber += addFieldAttributes(fieldBinding, fieldAttributeOffset);
if (this.contentsOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[fieldAttributeOffset++] = (byte) (attributeNumber >> 8);
this.contents[fieldAttributeOffset] = (byte) attributeNumber;
}
示例5: addMissingAbstractMethodFor
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public MethodDeclaration addMissingAbstractMethodFor(MethodBinding methodBinding) {
TypeBinding[] argumentTypes = methodBinding.parameters;
int argumentsLength = argumentTypes.length;
//the constructor
MethodDeclaration methodDeclaration = new MethodDeclaration(this.compilationResult);
methodDeclaration.selector = methodBinding.selector;
methodDeclaration.sourceStart = this.sourceStart;
methodDeclaration.sourceEnd = this.sourceEnd;
methodDeclaration.modifiers = methodBinding.getAccessFlags() & ~ClassFileConstants.AccAbstract;
if (argumentsLength > 0) {
String baseName = "arg";//$NON-NLS-1$
Argument[] arguments = (methodDeclaration.arguments = new Argument[argumentsLength]);
for (int i = argumentsLength; --i >= 0;) {
arguments[i] = new Argument((baseName + i).toCharArray(), 0L, null /*type ref*/, ClassFileConstants.AccDefault);
}
}
//adding the constructor in the methods list
if (this.missingAbstractMethods == null) {
this.missingAbstractMethods = new MethodDeclaration[] { methodDeclaration };
} else {
MethodDeclaration[] newMethods;
System.arraycopy(
this.missingAbstractMethods,
0,
newMethods = new MethodDeclaration[this.missingAbstractMethods.length + 1],
1,
this.missingAbstractMethods.length);
newMethods[0] = methodDeclaration;
this.missingAbstractMethods = newMethods;
}
//============BINDING UPDATE==========================
methodDeclaration.binding = new MethodBinding(
methodDeclaration.modifiers | ClassFileConstants.AccSynthetic, //methodDeclaration
methodBinding.selector,
methodBinding.returnType,
argumentsLength == 0 ? Binding.NO_PARAMETERS : argumentTypes, //arguments bindings
methodBinding.thrownExceptions, //exceptions
this.binding); //declaringClass
methodDeclaration.scope = new MethodScope(this.scope, methodDeclaration, true);
methodDeclaration.bindArguments();
/* if (binding.methods == null) {
binding.methods = new MethodBinding[] { methodDeclaration.binding };
} else {
MethodBinding[] newMethods;
System.arraycopy(
binding.methods,
0,
newMethods = new MethodBinding[binding.methods.length + 1],
1,
binding.methods.length);
newMethods[0] = methodDeclaration.binding;
binding.methods = newMethods;
}*/
//===================================================
return methodDeclaration;
}
示例6: SyntheticMethodBinding
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public SyntheticMethodBinding(FieldBinding targetField, ReferenceBinding declaringClass, TypeBinding enumBinding, char[] selector) {
this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic;
this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
SourceTypeBinding declaringSourceType = (SourceTypeBinding) declaringClass;
SyntheticMethodBinding[] knownAccessMethods = declaringSourceType.syntheticMethods();
int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
this.index = methodId;
this.selector = selector;
this.returnType = declaringSourceType.scope.createArrayType(TypeBinding.INT, 1);
this.parameters = Binding.NO_PARAMETERS;
this.targetReadField = targetField;
this.targetEnumType = enumBinding;
this.purpose = SyntheticMethodBinding.SwitchTable;
this.thrownExceptions = Binding.NO_EXCEPTIONS;
this.declaringClass = declaringSourceType;
if (declaringSourceType.isStrictfp()) {
this.modifiers |= ClassFileConstants.AccStrictfp;
}
// check for method collision
boolean needRename;
do {
check : {
needRename = false;
// check for collision with known methods
long range;
MethodBinding[] methods = declaringSourceType.methods();
if ((range = ReferenceBinding.binarySearch(this.selector, methods)) >= 0) {
int paramCount = this.parameters.length;
nextMethod: for (int imethod = (int)range, end = (int)(range >> 32); imethod <= end; imethod++) {
MethodBinding method = methods[imethod];
if (method.parameters.length == paramCount) {
TypeBinding[] toMatch = method.parameters;
for (int i = 0; i < paramCount; i++) {
if (toMatch[i] != this.parameters[i]) {
continue nextMethod;
}
}
needRename = true;
break check;
}
}
}
// check for collision with synthetic accessors
if (knownAccessMethods != null) {
for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
if (knownAccessMethods[i] == null) continue;
if (CharOperation.equals(this.selector, knownAccessMethods[i].selector) && areParametersEqual(methods[i])) {
needRename = true;
break check;
}
}
}
}
if (needRename) { // retry with a selector postfixed by a growing methodId
setSelector(CharOperation.concat(selector, String.valueOf(++methodId).toCharArray()));
}
} while (needRename);
// We now at this point - per construction - it is for sure an enclosing instance, we are going to
// show the target field type declaration location.
this.sourceStart = declaringSourceType.scope.referenceContext.sourceStart; // use the target declaring class name position instead
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:64,代码来源:SyntheticMethodBinding.java
示例7: addSyntheticFieldForEnumValues
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public FieldBinding addSyntheticFieldForEnumValues() {
if (this.synthetics == null)
this.synthetics = new HashMap[MAX_SYNTHETICS];
if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null)
this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5);
FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get("enumConstantValues"); //$NON-NLS-1$
if (synthField == null) {
synthField = new SyntheticFieldBinding(
TypeConstants.SYNTHETIC_ENUM_VALUES,
this.scope.createArrayType(this,1),
ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic | ClassFileConstants.AccFinal,
this,
Constant.NotAConstant,
this.synthetics[SourceTypeBinding.FIELD_EMUL].size());
this.synthetics[SourceTypeBinding.FIELD_EMUL].put("enumConstantValues", synthField); //$NON-NLS-1$
}
// ensure there is not already such a field defined by the user
// ensure there is not already such a field defined by the user
boolean needRecheck;
int index = 0;
do {
needRecheck = false;
FieldBinding existingField;
if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
TypeDeclaration typeDecl = this.scope.referenceContext;
FieldDeclaration[] fieldDeclarations = typeDecl.fields;
int max = fieldDeclarations == null ? 0 : fieldDeclarations.length;
for (int i = 0; i < max; i++) {
FieldDeclaration fieldDecl = fieldDeclarations[i];
if (fieldDecl.binding == existingField) {
synthField.name = CharOperation.concat(
TypeConstants.SYNTHETIC_ENUM_VALUES,
("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
needRecheck = true;
break;
}
}
}
} while (needRecheck);
return synthField;
}
示例8: addSyntheticFieldForInnerclass
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public FieldBinding addSyntheticFieldForInnerclass(ReferenceBinding enclosingType) {
if (this.synthetics == null)
this.synthetics = new HashMap[MAX_SYNTHETICS];
if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null)
this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5);
FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get(enclosingType);
if (synthField == null) {
synthField = new SyntheticFieldBinding(
CharOperation.concat(
TypeConstants.SYNTHETIC_ENCLOSING_INSTANCE_PREFIX,
String.valueOf(enclosingType.depth()).toCharArray()),
enclosingType,
ClassFileConstants.AccDefault | ClassFileConstants.AccFinal | ClassFileConstants.AccSynthetic,
this,
Constant.NotAConstant,
this.synthetics[SourceTypeBinding.FIELD_EMUL].size());
this.synthetics[SourceTypeBinding.FIELD_EMUL].put(enclosingType, synthField);
}
// ensure there is not already such a field defined by the user
boolean needRecheck;
do {
needRecheck = false;
FieldBinding existingField;
if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
TypeDeclaration typeDecl = this.scope.referenceContext;
FieldDeclaration[] fieldDeclarations = typeDecl.fields;
int max = fieldDeclarations == null ? 0 : fieldDeclarations.length;
for (int i = 0; i < max; i++) {
FieldDeclaration fieldDecl = fieldDeclarations[i];
if (fieldDecl.binding == existingField) {
if (this.scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5) {
synthField.name = CharOperation.concat(
synthField.name,
"$".toCharArray()); //$NON-NLS-1$
needRecheck = true;
} else {
this.scope.problemReporter().duplicateFieldInType(this, fieldDecl);
}
break;
}
}
}
} while (needRecheck);
return synthField;
}
示例9: initializeMethodAccessor
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
/**
* An method accessor is a method with an access$N selector, where N is incremented in case of collisions.
*/
public void initializeMethodAccessor(MethodBinding accessedMethod, boolean isSuperAccess, ReferenceBinding receiverType) {
this.targetMethod = accessedMethod;
this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic;
this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
SourceTypeBinding declaringSourceType = (SourceTypeBinding) receiverType;
SyntheticMethodBinding[] knownAccessMethods = declaringSourceType.syntheticMethods();
int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
this.index = methodId;
this.selector = CharOperation.concat(TypeConstants.SYNTHETIC_ACCESS_METHOD_PREFIX, String.valueOf(methodId).toCharArray());
this.returnType = accessedMethod.returnType;
this.purpose = isSuperAccess ? SyntheticMethodBinding.SuperMethodAccess : SyntheticMethodBinding.MethodAccess;
if (accessedMethod.isStatic()) {
this.parameters = accessedMethod.parameters;
} else {
this.parameters = new TypeBinding[accessedMethod.parameters.length + 1];
this.parameters[0] = declaringSourceType;
System.arraycopy(accessedMethod.parameters, 0, this.parameters, 1, accessedMethod.parameters.length);
}
this.thrownExceptions = accessedMethod.thrownExceptions;
this.declaringClass = declaringSourceType;
// check for method collision
boolean needRename;
do {
check : {
needRename = false;
// check for collision with known methods
MethodBinding[] methods = declaringSourceType.methods();
for (int i = 0, length = methods.length; i < length; i++) {
if (CharOperation.equals(this.selector, methods[i].selector) && areParameterErasuresEqual(methods[i])) {
needRename = true;
break check;
}
}
// check for collision with synthetic accessors
if (knownAccessMethods != null) {
for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
if (knownAccessMethods[i] == null) continue;
if (CharOperation.equals(this.selector, knownAccessMethods[i].selector) && areParameterErasuresEqual(knownAccessMethods[i])) {
needRename = true;
break check;
}
}
}
}
if (needRename) { // retry with a selector & a growing methodId
setSelector(CharOperation.concat(TypeConstants.SYNTHETIC_ACCESS_METHOD_PREFIX, String.valueOf(++methodId).toCharArray()));
}
} while (needRename);
// retrieve sourceStart position for the target method for line number attributes
AbstractMethodDeclaration[] methodDecls = declaringSourceType.scope.referenceContext.methods;
if (methodDecls != null) {
for (int i = 0, length = methodDecls.length; i < length; i++) {
if (methodDecls[i].binding == accessedMethod) {
this.sourceStart = methodDecls[i].sourceStart;
return;
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:68,代码来源:SyntheticMethodBinding.java
示例10: addSyntheticFieldForAssert
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public FieldBinding addSyntheticFieldForAssert(BlockScope blockScope) {
if (!isPrototype()) throw new IllegalStateException();
if (this.synthetics == null)
this.synthetics = new HashMap[MAX_SYNTHETICS];
if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null)
this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5);
FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get("assertionEmulation"); //$NON-NLS-1$
if (synthField == null) {
synthField = new SyntheticFieldBinding(
TypeConstants.SYNTHETIC_ASSERT_DISABLED,
TypeBinding.BOOLEAN,
(isInterface() ? ClassFileConstants.AccPublic : ClassFileConstants.AccDefault) | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic | ClassFileConstants.AccFinal,
this,
Constant.NotAConstant,
this.synthetics[SourceTypeBinding.FIELD_EMUL].size());
this.synthetics[SourceTypeBinding.FIELD_EMUL].put("assertionEmulation", synthField); //$NON-NLS-1$
}
// ensure there is not already such a field defined by the user
// ensure there is not already such a field defined by the user
boolean needRecheck;
int index = 0;
do {
needRecheck = false;
FieldBinding existingField;
if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
TypeDeclaration typeDecl = this.scope.referenceContext;
int max = (typeDecl.fields == null) ? 0 : typeDecl.fields.length;
for (int i = 0; i < max; i++) {
FieldDeclaration fieldDecl = typeDecl.fields[i];
if (fieldDecl.binding == existingField) {
synthField.name = CharOperation.concat(
TypeConstants.SYNTHETIC_ASSERT_DISABLED,
("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
needRecheck = true;
break;
}
}
}
} while (needRecheck);
return synthField;
}
示例11: addSyntheticFieldForEnumValues
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public FieldBinding addSyntheticFieldForEnumValues() {
if (!isPrototype()) throw new IllegalStateException();
if (this.synthetics == null)
this.synthetics = new HashMap[MAX_SYNTHETICS];
if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null)
this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5);
FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get("enumConstantValues"); //$NON-NLS-1$
if (synthField == null) {
synthField = new SyntheticFieldBinding(
TypeConstants.SYNTHETIC_ENUM_VALUES,
this.scope.createArrayType(this,1),
ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic | ClassFileConstants.AccFinal,
this,
Constant.NotAConstant,
this.synthetics[SourceTypeBinding.FIELD_EMUL].size());
this.synthetics[SourceTypeBinding.FIELD_EMUL].put("enumConstantValues", synthField); //$NON-NLS-1$
}
// ensure there is not already such a field defined by the user
// ensure there is not already such a field defined by the user
boolean needRecheck;
int index = 0;
do {
needRecheck = false;
FieldBinding existingField;
if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
TypeDeclaration typeDecl = this.scope.referenceContext;
FieldDeclaration[] fieldDeclarations = typeDecl.fields;
int max = fieldDeclarations == null ? 0 : fieldDeclarations.length;
for (int i = 0; i < max; i++) {
FieldDeclaration fieldDecl = fieldDeclarations[i];
if (fieldDecl.binding == existingField) {
synthField.name = CharOperation.concat(
TypeConstants.SYNTHETIC_ENUM_VALUES,
("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
needRecheck = true;
break;
}
}
}
} while (needRecheck);
return synthField;
}
示例12: addSyntheticFieldForSwitchEnum
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public SyntheticFieldBinding addSyntheticFieldForSwitchEnum(char[] fieldName, String key) {
if (!isPrototype()) throw new IllegalStateException();
if (this.synthetics == null)
this.synthetics = new HashMap[MAX_SYNTHETICS];
if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null)
this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5);
SyntheticFieldBinding synthField = (SyntheticFieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get(key);
if (synthField == null) {
synthField = new SyntheticFieldBinding(
fieldName,
this.scope.createArrayType(TypeBinding.INT,1),
(isInterface() ? (ClassFileConstants.AccPublic | ClassFileConstants.AccFinal) : ClassFileConstants.AccPrivate) | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic,
this,
Constant.NotAConstant,
this.synthetics[SourceTypeBinding.FIELD_EMUL].size());
this.synthetics[SourceTypeBinding.FIELD_EMUL].put(key, synthField);
}
// ensure there is not already such a field defined by the user
boolean needRecheck;
int index = 0;
do {
needRecheck = false;
FieldBinding existingField;
if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
TypeDeclaration typeDecl = this.scope.referenceContext;
FieldDeclaration[] fieldDeclarations = typeDecl.fields;
int max = fieldDeclarations == null ? 0 : fieldDeclarations.length;
for (int i = 0; i < max; i++) {
FieldDeclaration fieldDecl = fieldDeclarations[i];
if (fieldDecl.binding == existingField) {
synthField.name = CharOperation.concat(
fieldName,
("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
needRecheck = true;
break;
}
}
}
} while (needRecheck);
return synthField;
}
示例13: isSynthetic
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public final boolean isSynthetic() {
return (this.modifiers & ClassFileConstants.AccSynthetic) != 0;
}
示例14: initializeMethodAccessor
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
/**
* An method accessor is a method with an access$N selector, where N is incremented in case of collisions.
*/
public void initializeMethodAccessor(MethodBinding accessedMethod, boolean isSuperAccess, ReferenceBinding receiverType) {
this.targetMethod = accessedMethod;
if (isSuperAccess && receiverType.isInterface() && !accessedMethod.isStatic())
this.modifiers = ClassFileConstants.AccPrivate | ClassFileConstants.AccSynthetic;
else
this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic;
this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
SourceTypeBinding declaringSourceType = (SourceTypeBinding) receiverType;
SyntheticMethodBinding[] knownAccessMethods = declaringSourceType.syntheticMethods();
int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
this.index = methodId;
this.selector = CharOperation.concat(TypeConstants.SYNTHETIC_ACCESS_METHOD_PREFIX, String.valueOf(methodId).toCharArray());
this.returnType = accessedMethod.returnType;
this.purpose = isSuperAccess ? SyntheticMethodBinding.SuperMethodAccess : SyntheticMethodBinding.MethodAccess;
if (accessedMethod.isStatic() || (isSuperAccess && receiverType.isInterface())) {
this.parameters = accessedMethod.parameters;
} else {
this.parameters = new TypeBinding[accessedMethod.parameters.length + 1];
this.parameters[0] = declaringSourceType;
System.arraycopy(accessedMethod.parameters, 0, this.parameters, 1, accessedMethod.parameters.length);
}
this.thrownExceptions = accessedMethod.thrownExceptions;
this.declaringClass = declaringSourceType;
// check for method collision
boolean needRename;
do {
check : {
needRename = false;
// check for collision with known methods
MethodBinding[] methods = declaringSourceType.methods();
for (int i = 0, length = methods.length; i < length; i++) {
if (CharOperation.equals(this.selector, methods[i].selector) && areParameterErasuresEqual(methods[i])) {
needRename = true;
break check;
}
}
// check for collision with synthetic accessors
if (knownAccessMethods != null) {
for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
if (knownAccessMethods[i] == null) continue;
if (CharOperation.equals(this.selector, knownAccessMethods[i].selector) && areParameterErasuresEqual(knownAccessMethods[i])) {
needRename = true;
break check;
}
}
}
}
if (needRename) { // retry with a selector & a growing methodId
setSelector(CharOperation.concat(TypeConstants.SYNTHETIC_ACCESS_METHOD_PREFIX, String.valueOf(++methodId).toCharArray()));
}
} while (needRename);
// retrieve sourceStart position for the target method for line number attributes
AbstractMethodDeclaration[] methodDecls = declaringSourceType.scope.referenceContext.methods;
if (methodDecls != null) {
for (int i = 0, length = methodDecls.length; i < length; i++) {
if (methodDecls[i].binding == accessedMethod) {
this.sourceStart = methodDecls[i].sourceStart;
return;
}
}
}
}
示例15: addSyntheticFieldForAssert
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入方法依赖的package包/类
public FieldBinding addSyntheticFieldForAssert(BlockScope blockScope) {
if (this.synthetics == null)
this.synthetics = new HashMap[MAX_SYNTHETICS];
if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null)
this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5);
FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get("assertionEmulation"); //$NON-NLS-1$
if (synthField == null) {
synthField = new SyntheticFieldBinding(
TypeConstants.SYNTHETIC_ASSERT_DISABLED,
TypeBinding.BOOLEAN,
ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic | ClassFileConstants.AccFinal,
this,
Constant.NotAConstant,
this.synthetics[SourceTypeBinding.FIELD_EMUL].size());
this.synthetics[SourceTypeBinding.FIELD_EMUL].put("assertionEmulation", synthField); //$NON-NLS-1$
}
// ensure there is not already such a field defined by the user
// ensure there is not already such a field defined by the user
boolean needRecheck;
int index = 0;
do {
needRecheck = false;
FieldBinding existingField;
if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
TypeDeclaration typeDecl = this.scope.referenceContext;
int max = (typeDecl.fields == null) ? 0 : typeDecl.fields.length;
for (int i = 0; i < max; i++) {
FieldDeclaration fieldDecl = typeDecl.fields[i];
if (fieldDecl.binding == existingField) {
synthField.name = CharOperation.concat(
TypeConstants.SYNTHETIC_ASSERT_DISABLED,
("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
needRecheck = true;
break;
}
}
}
} while (needRecheck);
return synthField;
}