-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
When creating a functional interface in a java file, for example, Test1.java, and creating an object of the functional interface by implementing the abstract method in the interface inside the public static void main of the Test1 class, the anonymous inner class can access the local variables in the public static void main of the Test1 class, for example, the variables are called: name, age. However, if the variables are declared in the anonymous inner class, name, age, the anonymous inner class will ignore the local variables of outer class, and only use the variables inside the anonymous inner class. Therefore, the variables are separate from outer class and anonymous inner class. The problem is it can access the local variables of outer class since the interface is a separate class, it should not be able to access the variables of outer class even if it is declared in the main java class, Test1.
When creating a functional interface in a java file, for example, Test1.java, and creating an object of the functional interface by implementing the abstract method in the interface inside the public static void main of the Test1 class, the anonymous inner class can access the local variables in the public static void main of the Test1 class, for example, the variables are called: name, age. However, if the variables are declared in the anonymous inner class, name, age, the anonymous inner class will ignore the local variables of outer class, and only use the variables inside the anonymous inner class. Therefore, the variables are separate from outer class and anonymous inner class. The problem is it can access the local variables of outer class since the interface is a separate class, it should not be able to access the variables of outer class even if it is declared in the main java class, Test1.