Source:
<code>public void testLambdaSynthetic() throws JavaModelException { this.workingCopy = getWorkingCopy("/Converter18/src/xyz/X.java", true ); String contents = "package xyz;\n"+ "\n"+ "interface Function<T, R> {\n"+ " R apply(T t);\n"+ " }\n"+ "\n"+ "public class X {\n"+ "\n"+ " private int instanceField = 952;\n"+ "\n"+ " static public void main(String[] args) throws Exception {\n"+ " new X().callLambda(\"hello\");\n"+ " }\n"+ "\n"+ " void callLambda(String outerArg) throws Exception {\n"+ " double outerLocal = 1.0; "\n"+ " Function<String, Integer> lambda = lambdaArg -> {\n"+ " int lambdaLocal = 6;\n"+ " System.out.println(instanceField);\n"+ " System.out.println(outerArg);\n"+ " System.out.println(outerLocal);\n"+ " System.out.println(lambdaArg);\n"+ " System.out.println(lambdaLocal);\n"+ " return lambdaArg.length();\n"+ " };\n"+ " int result = lambda.apply(\"degenerate case\");\n"+ " System.out.println(result);\n"+ " }\n"+ "}\n"; CompilationUnit cu = (CompilationUnit) buildAST(contents, this.workingCopy); TypeDeclaration typedeclaration = (TypeDeclaration) getASTNode(cu, 1); MethodDeclaration methodDeclaration = (MethodDeclaration) typedeclaration.bodyDeclarations().get(2); VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(1); VariableDeclarationFragment fragment = (VariableDeclarationFragment)variableDeclarationStatement.fragments().get(0); Expression expression = fragment.getInitializer(); <START> assertTrue(expression <END> instanceof LambdaExpression); LambdaExpression lambdaExpression = (LambdaExpression)expression; IMethodBinding binding = lambdaExpression.resolveMethodBinding(); IVariableBinding[] synVars = binding.getSyntheticOuterLocals(); assertTrue(synVars.length == 2); assertEquals("val$outerArg",synVars[0].getName()); assertEquals("val$outerLocal",synVars[1].getName()); }</code><technical_language>I simply cast error actual type fail</technical_language>

Target:
public void testLambdaSynthetic() throws JavaModelException { this.workingCopy = getWorkingCopy("/Converter18/src/xyz/X.java", true ); String contents = "package xyz;\n"+ "\n"+ "interface Function<T, R> {\n"+ " R apply(T t);\n"+ " }\n"+ "\n"+ "public class X {\n"+ "\n"+ " private int instanceField = 952;\n"+ "\n"+ " static public void main(String[] args) throws Exception {\n"+ " new X().callLambda(\"hello\");\n"+ " }\n"+ "\n"+ " void callLambda(String outerArg) throws Exception {\n"+ " double outerLocal = 1.0; "\n"+ " Function<String, Integer> lambda = lambdaArg -> {\n"+ " int lambdaLocal = 6;\n"+ " System.out.println(instanceField);\n"+ " System.out.println(outerArg);\n"+ " System.out.println(outerLocal);\n"+ " System.out.println(lambdaArg);\n"+ " System.out.println(lambdaLocal);\n"+ " return lambdaArg.length();\n"+ " };\n"+ " int result = lambda.apply(\"degenerate case\");\n"+ " System.out.println(result);\n"+ " }\n"+ "}\n"; CompilationUnit cu = (CompilationUnit) buildAST(contents, this.workingCopy); TypeDeclaration typedeclaration = (TypeDeclaration) getASTNode(cu, 1); MethodDeclaration methodDeclaration = (MethodDeclaration) typedeclaration.bodyDeclarations().get(2); VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(1); VariableDeclarationFragment fragment = (VariableDeclarationFragment)variableDeclarationStatement.fragments().get(0); LambdaExpression lambdaExpression = (LambdaExpression) fragment.getInitializer(); IMethodBinding binding = lambdaExpression.resolveMethodBinding(); IVariableBinding[] synVars = binding.getSyntheticOuterLocals(); assertEquals(2, synVars.length); assertEquals("val$outerArg",synVars[0].getName()); assertEquals("val$outerLocal",synVars[1].getName()); }