Load a class from the users workspace

时间秒杀一切 提交于 2019-12-24 02:13:10

问题


I´m writing an eclipse plugin which should show some information of an enum class. The new view should show all enum constants and the assigned values. The enum values are calculated in the constructor somehow and it is not obvious in the editor which value they will have at runtime. So that´s the motivation for the plugin. I have tried to access the class which is opened in the editor by the eclipse AST. That way I´m getting the enum constant names of that file but not the assigned values at runtime.

So how can I get the enum values? Is it possible to load a class from the user´s workspace and use reflection to access the values of that class?


回答1:


I have solved this on the dirty way: I am looking up the .class file from the bin directory, loading it and grabbing the values on this way.



来源:https://stackoverflow.com/questions/7358624/load-a-class-from-the-users-workspace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!