怎样把一个package下所有class列出来啊.docVIP

  • 4
  • 0
  • 约1.31万字
  • 约 11页
  • 2018-07-10 发布于湖北
  • 举报

怎样把一个package下所有class列出来啊.doc

1.怎样把一个package下的所有class列出来啊? HYPERLINK javascript:copyText(document.all.text141726); Copy to clipboardPosted by: xxrong Posted on: 2005-04-19 10:17 I want to perform a test over all class in package com.mytest. All class in this class extends the same super class. This is my idea: for(each class clazz in packagecom.mytest){ SuperClass sobjct=clazz.newInstant(); Method m=sobjct.getMethod(test,...); //invoke test(...) sobject.invoke(...); } How can I do this? 2.Re:怎样把一个package下的所有class列出来啊? [Re: xxrong] HYPERLINK javascript:copyText(document.all.text142149); Copy to clipboardPosted by: 凤舞凰扬 Posted on: 2005-04-22 16:32 I think you should know the naming rule about java class. You can get the file list under the package at first. To iterate the file list and build a string which is the same as class name (for example , if your package is com.mytest , the string would be com.mytest.xxxx). And then , you transfer it into a class via reflect . You can use the function isAssignableFrom and judge whether the super class of current class is what you want. 3.Re:怎样把一个package下的所有class列出来啊? [Re: xxrong] HYPERLINK javascript:copyText(document.all.text142158); Copy to clipboardPosted by: jigsaw Posted on: 2005-04-22 17:33 缺乏上下文。。。 你得package在哪? 一个路径?一个jar? 要么用File 要么用ZipFile 4.Re:怎样把一个package下的所有class列出来啊? [Re: xxrong] HYPERLINK javascript:copyText(document.all.text142398); Copy to clipboardPosted by: 凤舞凰扬 Posted on: 2005-04-25 13:32 楼上的回复就不恰当了,要列出一个包下的所有类,前提当然是这个类是可以访问的,也就是自然要在classpath下的。不清楚所所的package在哪是什么意思?更不清楚什么叫一个路径,再说了,文件夹也好,jar也好,对class的装载是没有区别的,需要去考虑么? 这个问题非常的简单,就是如同IDE的代码助手一样(敲一个.就列出包下的类),唯一需要注意的仅仅是类的可访问性(比如说有的类不是public,而是包访问或者protected) 5.Re:怎样把一个package下的所有class列出来啊? [Re: 凤舞凰扬] HYPERLINK javascript:copyText(document.all.text142400); Copy to clipboardPosted by: Jove Posted on: 2005-04-25 13:50 IDE的做法应该也是设置好BuildPath或ClassPath后,对所有项目作一次检查,把类名都收集起来,所以或许不存在一个通用而简单的方法列出同一个Package的所有Class 6.Re:怎样把一个package下的所有class列出来啊? [Re: 凤舞凰扬] HYPERLINK javascript:copyText(document

文档评论(0)

1亿VIP精品文档

相关文档