静的メソッドへのアクセスに使用されたクラスの名前を計算することはできますか?java get静的メソッドのクラス名
より良い質問を理解するために:
class S {
public static String method() {
return "S";// TODO compute class name here
}
}
class S1 extends S {
}
class S2 extends S {
}
public class Main {
public static void main(String[] args) {
System.out.println(S.method()); //should print S
System.out.println(S1.method()); //should print S1
System.out.println(S2.method()); //should print S2
}
}
を私はどちらもスタックトレースNOR型パラメータの技術を使用することはできませんようです。
おかげ
@DVargaこれはまったく異なる質問です。 – dasblinkenlight
[getName()](https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getName())がありますが、この特殊なケースは解決しません。 –
あなたはこれを求めているのですか、それとも別の問題を解決しようとしますか?この機能の目的は何ですか? – Tom