提供类和LT是否有可能实例化一个Java注解的;?扩展注解&GT ;? [英] Is it possible to instantiate a Java Annotation given a Class<? extends Annotation>?
本文介绍了提供类和LT是否有可能实例化一个Java注解的;?扩展注解&GT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类和LT ;?扩展注解&GT;
和打过电话的newInstance()
,但Java的我大声吼叫了,我不能实例化的界面明显的原因。但我知道像EasyMock的框架是完全能够实例接口。会是什么才能让一个完全哑注释
实例出我的类
?
I have a Class<? extends Annotation>
and tried calling newInstance()
but Java yelled at me for the obvious reason that I can't instantiate an interface. But I know frameworks like EasyMock are perfectly capable of instantiating interfaces. What would it take to get a completely dumb Annotation
instance out of my Class
?
推荐答案
模拟框架没有实例化的接口,他们建立实现它们在运行时动态类。您可能会发现这个javadoc的启发获取你想要做什么!
Mock frameworks do not instantiate interfaces, they build classes that implement them on the fly at runtime. You may find this javadoc enlightening for what you want to do!
这篇关于提供类和LT是否有可能实例化一个Java注解的;?扩展注解&GT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文