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

fix(agama): re-engineer how calls are working in the engine #7064

Closed
jgomer2001 opened this issue Dec 12, 2023 · 3 comments · Fixed by #7152
Closed

fix(agama): re-engineer how calls are working in the engine #7064

jgomer2001 opened this issue Dec 12, 2023 · 3 comments · Fixed by #7152
Assignees
Labels
comp-agama Touching folder /agama kind-bug Issue or PR is a bug in existing functionality

Comments

@jgomer2001
Copy link
Contributor

Case 1. Suppose

map = Call java.util.Collections#emptyMap
Call map size

it fails miserably with:

Caused by: java.lang.IllegalAccessException: class io.jans.agama.engine.service.ActionService cannot access a member of class java.util.Collections$EmptyMap (in module java.base) with modifiers "public"
	at jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392) ~[?:?]
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:560) ~[?:?]
	at io.jans.agama.engine.service.ActionService.callAction(ActionService.java:146) ~[agama-engine-1.0.21-SNAPSHOT.jar:?]

This is because the class returned is a sort of inner class (java.util.Collections$EmptyMap) and its size method is not accessible by external code - the method enforces access control despite it's public

Same issues occur when trying to Call methods on objects returned by Calls like java.util.Map#of ... and similar


Case 2. Suppose

package co;

public class SubTest extends Test {
    ...
}

...

package co;

public class Test {

    private String id;

    public String getId() {
        return id;
    }
    ....
}

and

obj = Call co.SubTest#new
Call obj getId

It fails with NoSuchMethodException: Unable to find a method called getId with arity 0 in class co.SubTest

The implementation is not scanning methods in the parent class

@jgomer2001 jgomer2001 self-assigned this Dec 12, 2023
@mo-auto mo-auto added comp-agama Touching folder /agama kind-bug Issue or PR is a bug in existing functionality labels Dec 12, 2023
@jgomer2001
Copy link
Contributor Author

Case 3. A call like

Call one.two.three#new

Crahes with InvocationTargetException if the underlying constructor throws an exception. It should throw the original exception without wrapping it

@jgomer2001
Copy link
Contributor Author

case 4. A call like

Call p method param

where p is an unknown (unset) variable in the flow, degenerates in attempts to lookup method on the String class.

This seems to be that way because an instance of org.mozilla.javascript.Undefined is received, and the getClass method on it seems to give String.

@jgomer2001
Copy link
Contributor Author

case 5. A call like

s = "a string"
Call instance method s

where method has param of type char[] or Character[] fails. The conversion is only succeeding when the param is exactly CharSequence, String or char

jgomer2001 added a commit that referenced this issue Dec 19, 2023
Signed-off-by: jgomer2001 <bonustrack310@gmail.com>
jgomer2001 added a commit that referenced this issue Dec 19, 2023
Signed-off-by: jgomer2001 <bonustrack310@gmail.com>
jgomer2001 added a commit that referenced this issue Dec 19, 2023
Signed-off-by: jgomer2001 <bonustrack310@gmail.com>
@jgomer2001 jgomer2001 changed the title fix(agama): some calls do not work fix(agama): re-engineer how calls work in the engine Dec 19, 2023
@jgomer2001 jgomer2001 changed the title fix(agama): re-engineer how calls work in the engine fix(agama): re-engineer how calls are working in the engine Dec 19, 2023
yurem pushed a commit that referenced this issue Dec 19, 2023
* docs: update docs wrt engine updates #7064

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

* test: update and augment test cases and related resources #7064 #6997

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

* fix: revamp method selection & argument conversion strategy #7064


Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

---------

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>
devrimyatar pushed a commit that referenced this issue Dec 30, 2023
* docs: update docs wrt engine updates #7064

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

* test: update and augment test cases and related resources #7064 #6997

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

* fix: revamp method selection & argument conversion strategy #7064

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

---------

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>
Signed-off-by: Mustafa Baser <mbaser@mail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-agama Touching folder /agama kind-bug Issue or PR is a bug in existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants