override java final methods via reflection or other means?

前端 未结 6 1655
醉梦人生
醉梦人生 2020-12-15 09:28

This question arise while trying to write test cases. Foo is a class within the framework library which I dont have source access to.

public class Foo{
  pub         


        
6条回答
  •  暖寄归人
    2020-12-15 09:48

    Seb is correct, and just to ensure that you get an answer to your question, short of doing something in native code (and I am pretty sure that would not work) or modifying the bytecode of the class at runtime, and creating the class that overrides the method at runtime, I cannot see a way to alter the "finalness" of a method. Reflection will not help you here.

提交回复
热议问题