You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given an instance (matched dynamically) I want to directly access the corresponding class (so that I can patch a target method for all instances).
This feels like something that it should be possible to do efficiently, but the best way I can see to do this right now is with Java.use(instance.$className). That seems likely to be slow and potentially error prone (if the instance comes from an unexpected classloader, for example).
There is an instance.class property, but this returns <instance: java.lang.Class>, rather than <class: $CLASS_NAME>. There's also various $-prefixed single character fields, but I assume those aren't intended to be used directly, and none seems to obviously provide this.
Is there a more direct way to do this? Am I wildly off track somehow?
If not, would you be open to adding a method for this? I'd be happy to open a PR. I think in general, it might be useful to add a small section to the docs related to this, defining the JS API that's available (e.g. $className) on Java instances and classes.
The text was updated successfully, but these errors were encountered:
Given an instance (matched dynamically) I want to directly access the corresponding class (so that I can patch a target method for all instances).
This feels like something that it should be possible to do efficiently, but the best way I can see to do this right now is with
Java.use(instance.$className)
. That seems likely to be slow and potentially error prone (if the instance comes from an unexpected classloader, for example).There is an
instance.class
property, but this returns<instance: java.lang.Class>
, rather than<class: $CLASS_NAME>
. There's also various $-prefixed single character fields, but I assume those aren't intended to be used directly, and none seems to obviously provide this.Is there a more direct way to do this? Am I wildly off track somehow?
If not, would you be open to adding a method for this? I'd be happy to open a PR. I think in general, it might be useful to add a small section to the docs related to this, defining the JS API that's available (e.g.
$className
) on Java instances and classes.The text was updated successfully, but these errors were encountered: