protected void setSelfTypeInInitializationCode( Tree tree, AnnotatedDeclaredType selfType, TreePath path) { ClassTree enclosingClass = TreeUtils.enclosingClass(path); Type classType = ((JCTree) enclosingClass).type; AnnotationMirror annotation = null; // If all fields are committed-only, and they are all initialized, // then it is save to switch to @UnderInitialization(CurrentClass). if (areAllFieldsCommittedOnly(enclosingClass)) { Store store = getStoreBefore(tree); if (store != null) { List<AnnotationMirror> annos = Collections.emptyList(); if (getUninitializedInvariantFields(store, path, false, annos).size() == 0) { if (useFbc) { annotation = createFreeAnnotation(classType); } else { annotation = createUnclassifiedAnnotation(classType); } } } } if (annotation == null) { annotation = getFreeOrRawAnnotationOfSuperType(classType); } selfType.replaceAnnotation(annotation); }
@Override public Void visitExecutable(AnnotatedExecutableType t, Void p) { Void result = super.visitExecutable(t, p); Element elem = t.getElement(); if (elem.getKind() == ElementKind.CONSTRUCTOR) { AnnotatedDeclaredType returnType = (AnnotatedDeclaredType) t.getReturnType(); DeclaredType underlyingType = returnType.getUnderlyingType(); returnType.replaceAnnotation(getFreeOrRawAnnotationOfSuperType(underlyingType)); } return result; }