Dynamically create an extended anonymous class from a given INSTANCE (override a method from an instance in runtime)
问题 Is there any way to create dynamically an extended anonymous instance given another one? Would be something like this, and I think it would be great. File myFile = new File("notes.txt"); new FileWrapper extends myFile(){ //instance!!! @Override public boolean equals(File in){ return false;} }; This is like copying the object instance and rewritting the logic inside a particular method If not whats the best way of achieving it? Note: I know that the example is valid if myFile is a class´s name