Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refelection support ? #746

Open
maheshkurmi opened this issue Dec 16, 2022 · 1 comment
Open

Refelection support ? #746

maheshkurmi opened this issue Dec 16, 2022 · 1 comment

Comments

@maheshkurmi
Copy link

Does jsweet support reflection? Upto what extent?
Following do not work

  1. creating instance from constructor definion?
  2. Class.isInstanceOf method doesn't exist
  3. Passing String.class (or Double.class) as parameter 'Class' throws
    Argument of type 'StringConstructor' is not assignable to parameter of type
  4. ClassArray using Array.newInstance(itemClas, 0).getClass() throws error
@lgrignon
Copy link
Collaborator

Hello @maheshkurmi

JSweet has minimal support for reflection. It depends on whether you use J4TS or not, but you can expect basic introspection to be available (get methods of a class, get class name, get method name .. you can find detailed implementations in JSweet adapter: https://github.com/cincheo/jsweet/blob/develop/transpiler/src/main/java/org/jsweet/transpiler/extension/Java2TypeScriptAdapter.java#L1271)

but AFAIR you cannot expect to create instances dynamically with newInstance.

Please also read: https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md#allowed-java-objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants