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

gosh_profile errors on startup of substrate #71

Open
fipro78 opened this issue Sep 30, 2022 · 3 comments
Open

gosh_profile errors on startup of substrate #71

fipro78 opened this issue Sep 30, 2022 · 3 comments

Comments

@fipro78
Copy link
Contributor

fipro78 commented Sep 30, 2022

If I try to configure a custom gosh_profile and motd with the created substrate I get the following error:

/gosh_profile: ERROR: java.lang.IllegalArgumentException: Cannot coerce resolve(Token) to any of []

With the Atomos substrate examples the error looks a bit different, but almost the same:

gosh_profile: ERROR: java.lang.IllegalArgumentException: Cannot coerce addcommand(Token, BundleContextImpl) to any of []

Somehow the gosh_profile execution does not work correctly.
I tried several things to make it work, but I don't get the point what is missing in the reflection configuration. Even using the java_agent and inspecting the resulting configs did not uncover anything related to this specific thing. Any ideas what could be missing?

@fipro78
Copy link
Contributor Author

fipro78 commented Sep 30, 2022

Further investigation results:

I added the following blocks to the reflect-config.json to make some things work:

  {
    "name" : "java.lang.Exception",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true,
    "allDeclaredClasses" : true,
    "allPublicClasses" : true
  },
  {
    "name": "org.apache.felix.gogo.command.Basic",
    "allPublicConstructors": true,
    "allPublicMethods": true,
    "allDeclaredMethods": true,
    "allPublicFields": true,
    "allDeclaredFields": true,
    "methods":[{"name":"resolve","parameterTypes":["org.osgi.framework.Bundle[]"] }]
  },
  {
    "name": "org.apache.felix.gogo.runtime.CommandProcessorImpl",
    "allPublicMethods": true,
    "allDeclaredMethods": true,
    "allPublicFields": true,
    "allDeclaredFields": true
  },

This way the error with addCommand is gone and I am able to use the exception function in the Gogo shell. But the resolve method is still not working.

@fipro78
Copy link
Contributor Author

fipro78 commented Sep 30, 2022

The issue about the resolve command seems to come out of this gosh_profile line

if { $.gosh_quiet } { } { cat ($0 resolve motd) }

In the substrate version the resolve seems to be not resolved correctly for whatever reason (I wonder why it works as resolve takes a Bundle[] argument and motd is a simple file). I changed this to

if { $.gosh_quiet } { } { cat ./etc/motd }

which makes an assumption on the location of the motd file. Maybe this can be done in a more elegant way, but my Gogo shell scripting knowledge is not that experienced.

Anyhow, it doesn't seem to be an issue in Atomos, maybe interesting for the examples to add the handling of the exit command etc. I'll leave it to the Atomos team if the ticket should be closed or not, dependent on the decision if it is important for the examples.

@tjwatson
Copy link
Member

Perhaps open an issue against felix-dev to consider adding a native image resource file to gogo that includes the necessary reflection config json files it needs to make it work with native image?

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