List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeConstants SYNTHETIC_CLASS
null SYNTHETIC_CLASS
To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeConstants SYNTHETIC_CLASS.
Click Source Link
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
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);/*from w ww . j a va 2 s. com*/ 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; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectReader.java
License:Open Source License
private FieldBinding getFieldRef(int index) { int start = getConstantPoolStartPosition(index); assert (u1At(start) == FieldRefTag); int class_index = u2At(start + 1); int name_index = u2At(start + 3); ReferenceBinding class_rb = getClassBinding(class_index); ReferenceBinding actualReceiver = class_rb; if (class_rb == null) return null; char[][] nameandtype = getNameAndType(name_index); char[] name = nameandtype[0]; char[] type = nameandtype[1]; FieldBinding fb = null;/*from www. j a v a2 s . com*/ if (class_rb.erasure() instanceof SourceTypeBinding) { SourceTypeBinding sourceType = (SourceTypeBinding) class_rb.erasure(); // can't find synthetics in 'fields'. if (CharOperation.prefixEquals(TypeConstants.SYNTHETIC_OUTER_LOCAL_PREFIX, name)) return sourceType.getSyntheticOuterLocal(name); if (CharOperation.prefixEquals(TypeConstants.SYNTHETIC_CLASS, name)) return sourceType.getSyntheticClassLiteral(name); } // FIXME(SH): else read from RoleModel?? do { fb = findFieldBinding(class_rb, name, type); if (fb != null) { if (TypeBinding.notEquals(actualReceiver, class_rb)) // return sourceType.getUpdatedFieldBinding(fb, actualReceiver); // no sourceType available so directly create the updated binding: return new FieldBinding(fb, actualReceiver); return fb; } class_rb = class_rb.superclass(); } while (!CharOperation.equals(class_rb.constantPoolName(), ConstantPool.JavaLangObjectConstantPoolName)); return fb; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectReader.java
License:Open Source License
public static FieldBinding findFieldByBinding(ReferenceBinding clazz, FieldBinding refField) { char[] thisPrefix = TypeConstants.SYNTHETIC_ENCLOSING_INSTANCE_PREFIX; char[] classPrefix = TypeConstants.SYNTHETIC_CLASS; char[] name = refField.name; if (CharOperation.prefixEquals(thisPrefix, name)) { int distance = refField.declaringClass.depth() - ((ReferenceBinding) refField.type).depth(); if (clazz instanceof NestedTypeBinding) { {//w w w . j av a 2 s.c o m NestedTypeBinding mtb = (NestedTypeBinding) clazz; ReferenceBinding dstFieldType = clazz; while (distance-- > 0) { dstFieldType = dstFieldType.enclosingType(); } return mtb.addSyntheticFieldForInnerclass(dstFieldType); } } else { // BinaryTypeBinding int depth = clazz.depth() - distance; name = CharOperation.concat(thisPrefix, String.valueOf(depth).toCharArray()); } } else if (CharOperation.prefixEquals(classPrefix, name)) { // assume the synthetic field is present, just create a new binding. return new FieldBinding(refField.name, refField.type, 0, clazz, null); } // directly find field in clazz or superclass(es) ReferenceBinding current = clazz; while (current != null) { FieldBinding f = current.getField(name, true); if (f != null) return f; current = current.superclass(); } return null; }