JUtils { public static boolean isEffectivelyFinal(Symbol.VariableSymbol variableSymbol) { return ((IVariableBinding) ((JVariableSymbol) variableSymbol).binding).isEffectivelyFinal(); } private  JUtils(); static boolean isPrimitiveWrapper(Type type); @Nullable static Type primitiveWrapperType(Type type); @Nullable static Type primitiveType(Type type); static boolean isNullType(Type type); static boolean isIntersectionType(Type type); static boolean isTypeVar(Type type); static boolean isAnnotation(Symbol.TypeSymbol typeSymbol); static boolean isEffectivelyFinal(Symbol.VariableSymbol variableSymbol); static boolean isParameter(Symbol symbol); static Optional<Object> constantValue(Symbol.VariableSymbol symbol); static Set<Type> superTypes(Symbol.TypeSymbol typeSymbol); static Symbol.TypeSymbol outermostClass(Symbol.TypeSymbol typeSymbol); static Symbol getPackage(Symbol symbol); static boolean isVarArgsMethod(Symbol.MethodSymbol method); static boolean isSynchronizedMethod(Symbol.MethodSymbol method); static boolean isNativeMethod(Symbol.MethodSymbol method); static boolean isDefaultMethod(Symbol.MethodSymbol method); @Nullable static Object defaultValue(Symbol.MethodSymbol method); static boolean isOverridable(Symbol.MethodSymbol method); static boolean isParametrizedMethod(Symbol.MethodSymbol method); static boolean isRawType(Type type); static Type declaringType(Type type); static Set<Type> directSuperTypes(Type type); @Nullable static Symbol enclosingClass(Tree t); @Nullable static Symbol importTreeSymbol(ImportTree tree); static Symbol typeParameterTreeSymbol(TypeParameterTree tree); static SymbolMetadata parameterAnnotations(Symbol.MethodSymbol method, int param);  }
@Test void effectivelyFinal() { JavaTree.CompilationUnitTreeImpl cu = test("class A { void foo(Object o) { int i = 42; int j = 43; j++; foo(i); } }"); ClassTreeImpl a = (ClassTreeImpl) cu.types().get(0); MethodTreeImpl m = (MethodTreeImpl) a.members().get(0); List<StatementTree> body = m.block().body(); VariableTreeImpl i = (VariableTreeImpl) body.get(0); VariableTreeImpl j = (VariableTreeImpl) body.get(1); assertThat(i.symbol().isVariableSymbol()).isTrue(); assertThat(JUtils.isEffectivelyFinal((Symbol.VariableSymbol) i.symbol())).isTrue(); assertThat(j.symbol().isVariableSymbol()).isTrue(); assertThat(JUtils.isEffectivelyFinal((Symbol.VariableSymbol) j.symbol())).isFalse(); }