ExpressionUtils { public static boolean isSecuringByte(ExpressionTree expression) { if (expression.is(Tree.Kind.AND)) { BinaryExpressionTree and = (BinaryExpressionTree) expression; return LiteralUtils.is0xff(and.rightOperand()) || LiteralUtils.is0xff(and.leftOperand()); } return false; } private  ExpressionUtils(); static boolean isSimpleAssignment(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(MemberSelectExpressionTree tree); static IdentifierTree extractIdentifier(AssignmentExpressionTree tree); static Optional<Symbol> extractIdentifierSymbol(ExpressionTree tree); static boolean isInvocationOnVariable(MethodInvocationTree mit, @Nullable Symbol variable, boolean defaultReturn); static ExpressionTree skipParentheses(ExpressionTree tree); static boolean isNullLiteral(ExpressionTree tree); static boolean isSecuringByte(ExpressionTree expression); static IdentifierTree methodName(MethodInvocationTree mit); @CheckForNull static MethodTree getEnclosingMethod(ExpressionTree expr); static Optional<Symbol> getAssignedSymbol(ExpressionTree exp); static boolean isThis(ExpressionTree expression); @CheckForNull static Object resolveAsConstant(ExpressionTree tree);  }
@Test void securing_byte() { CompilationUnitTree tree = JParserTestUtils.parse( "class A {\n" + " static {\n" + " int i1 = 12;\n" + " int i2 = 12 & 0xFF;\n" + " int i3 = 0xff & 12;\n" + " int i4 = 12 & 12;\n" + " }\n" + "}"); StaticInitializerTree staticInitializer = (StaticInitializerTree) ((ClassTree) tree.types().get(0)).members().get(0); List<ExpressionTree> expressions = staticInitializer.body().stream() .map(VariableTree.class::cast) .map(VariableTree::initializer) .collect(Collectors.toList()); assertThat(ExpressionUtils.isSecuringByte(expressions.get(0))).isFalse(); assertThat(ExpressionUtils.isSecuringByte(expressions.get(1))).isTrue(); assertThat(ExpressionUtils.isSecuringByte(expressions.get(2))).isTrue(); assertThat(ExpressionUtils.isSecuringByte(expressions.get(3))).isFalse(); }