k*****c 发帖数: 6 | 1 现在有一个类的.class文件,想获得这个类定义的public methods。
使用下面的方法来做。但对于某些类,在运行到theClass.getMethods()时就出ClassNotF
oundException(而且不能被我程序的异常处理捕获,直接退出到命令行),因为那个类引
用了一些在我的机器上没有的类。
//Class theClass=classLoader.loadClass(sClassName);
Class theClass=Class.forName(sClassName,false,classLoader);
allMethods=theClass.getMethods();
我的目的是只想得到这个类定义的所有公开功能,并不是要使用这个类。
(当然可以用decompiler去看,但我要处理大量的类,想通过程序做)
应该有办法获得吧,就象IDE可以列出类的所有功能。
请指教。谢谢! |
|
S*******s 发帖数: 13043 | 2 I got an error if I want to run test.py:
@singleton
NameError: name 'singleton' is not defined
if I combine the two files, it would be fine.
what is right way to import decorator?
#in module Singleton.py
def singleton(theClass):
""" decorator for a class to make a singleton out of it """
classInstances = {}
def getInstance(*args, **kwargs):
""" creating or just return the one and only class instance.
The singleton depends on the parameters used in __init__ """... 阅读全帖 |
|
f**********n 发帖数: 29853 | 3 接下来,UT律师时间,开场白之后,保守派大法官alito 质问,我觉得你的辩护有一点
让我不舒服,就是你假设头十趴里招的黑人和西裔很差,这个是偏见。
律师反驳如下,我全文拷贝,不翻译。
It'sexactlytheopposite. This Courthassaidtime
andagainthatyoucan'tassumethat minoritiesthink
alikejustbecausetheyhavetthesame
skincolor.WhattheUniversityofTexasdoesis it
considersittakesintoaccountthefact
thatpeople whocomefromdifferentexperiences,different
backgroundsaregoingtohavedifferentcontributions to
theclass. Ifyouhadthesituationwhereall
the outofStateadmitsormostoftheout
of Stateadmits
werecomin... 阅读全帖 |
|
d*r 发帖数: 238 | 4 For example, I have a class
class Class1
{
bool b;
int i;
string s;
}
How to write/read an object of Class1, say theClass, into/from an xml file
without worrying the structre of the class.
In java, I can use XmlEncoder.writeObject() and XmlDecoder.readObject(). |
|
e***g 发帖数: 158 | 5 System.setProperty(..);
TheClass.main(..); |
|