[Soot-list] Trying to do getClass() on a static method...need to implement inner classes
Eric Bodden
bodden at st.informatik.tu-darmstadt.de
Fri Jun 18 03:06:41 EDT 2010
> This wouldn't work as I want the runtime class of the called static method.
> The constant could only correspond to the declaring class (,if I am not
> wrong) and doesn't give me the proper class in case of derived classes.
>
> To continue your example, if I have another class:
>
> class Oof extends Foo {
> ...
> }
>
> , I want to get a handle to Oof inside the call:
> Oof.bar(); // where bar() is the static method defined in class Foo
>
> and Foo inside Foo.bar().
>
> I must admit that I am still getting used to Java, and might have missed
> some of its inheritance concepts, but new Object()
> {}.getClass().getEnclosingClass() is what I found should work here. If there
> is any other way, I'd be really glad to try that out too.
I guess you are right. I forgot that in Java you can actually
inherit static methods. (I wonder if people actually use this
feature.) Yes in that case I also cannot think of another simple way
to solve this.
Regarding your original question: can you please use the flags "-f
jasmin" to Soot? This will output the classes as .jasmin files. Then
please check if the jasmin file for your class contains appropriate
inner-class attributes. If it does not, then we know that something is
wrong with the attribute generation.
Eric
More information about the Soot-list
mailing list