graalvm

Benjamin 2022-05-07T11:10:38.412379Z

what is your general approach to making some java lib compile / run? issue in thread

Benjamin 2022-05-07T11:11:14.115119Z

runtime error when I call some static constructor thingy:

Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.google.api.client.googleapis.javanet.GoogleNetHttpTransport.newTrustedTransport(GoogleNetHttpTransport.java:87)
	at com.google.api.client.googleapis.javanet.GoogleNetHttpTransport.newTrustedTransport(GoogleNetHttpTransport.java:58)
	at google_api_clj.google_client$create_google_client.invokeStatic(google_client.clj:29)
...
Caused by: java.lang.IllegalStateException: No match found
	at java.util.regex.Matcher.group(Matcher.java:645)
	at com.google.api.client.googleapis.GoogleUtils.<clinit>(GoogleUtils.java:66)
	... 9 more
https://cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.javanet.GoogleNetHttpTransport I'm not sure but I think it is because it caches something when it initializes

borkdude 2022-05-07T11:13:37.283049Z

Are you using /constructing these objects from classes outside of functions?

Benjamin 2022-05-07T11:14:53.045649Z

I import the namespace package and call a static method in a function in a clojure namespace

borkdude 2022-05-07T11:15:26.692729Z

How do your --initialize-at-build-time settings look?

Benjamin 2022-05-07T11:16:09.871999Z

"--initialize-at-build-time=com.google.api.client.util.DateTime"
    "--initialize-at-build-time=com.google.common.base.Preconditions"
    "--initialize-at-build-time=com.google.api.client.util.Data"
    "--initialize-at-build-time=com.google.common.base.Preconditions"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.Spreadsheet"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.RowData"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.Sheet"

    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.DimensionProperties"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.FilterView"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.GridData"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.ProtectedRange"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.DimensionProperties"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.FilterView"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.ProtectedRange"
    "--initialize-at-build-time=com.google.api.services.sheets.v4.model.GridData"
I just naively put all classes that graalvm threw as warning

borkdude 2022-05-07T11:16:35.931929Z

you probably should avoid doing that

Benjamin 2022-05-07T11:17:13.515119Z

I see so it's initializing something that shouldn't be

borkdude 2022-05-07T11:17:21.901259Z

yes, hence the "caching"

Benjamin 2022-05-07T11:17:53.384519Z

ah so I should figure out why it is initialized. And do the delay trick

borkdude 2022-05-07T11:19:20.463579Z

yes. but it might be coming from your https://github.com/viebel/google-api-clj library you mentioned earlier.

Benjamin 2022-05-07T11:19:52.064519Z

oh yes I'll to go into there 😛

Benjamin 2022-05-07T11:20:07.151479Z

thamnks thanks bro

Benjamin 2022-05-07T13:32:44.755209Z

I got rid of all the build time initializing, unfortunately I still have this issue:

Caused by: java.lang.IllegalStateException: No match found
        at java.util.regex.Matcher.group(Matcher.java:645)
        at com.google.api.client.googleapis.GoogleUtils.<clinit>(GoogleUtils.java:66)
        ... 9 more

Benjamin 2022-05-07T13:39:39.522779Z

now I'm on another lead. I decompiled this GoogleUtils class with intellij and see there is some hardcoded regex pattern making assumption about the version string. This is promising because I just set the version to the git sha it is using some .properties "resource". I saw there is a way to define resources for graalvm right? ok I'm doing it https://www.graalvm.org/22.1/reference-manual/native-image/Resources/

borkdude 2022-05-07T14:26:22.421809Z

right

Benjamin 2022-05-07T15:11:13.175789Z

isn't there some nice way to declare classes I use in my clojure code? Atm I'm adding classes 1 by 1 to my reflection.json config 😅

borkdude 2022-05-07T15:19:53.250979Z

instead of doing that, you should probably get rid of reflection anyway

borkdude 2022-05-07T15:20:12.799519Z

(set! **warn-on-reflection** true)

Benjamin 2022-05-07T15:20:36.835419Z

ok I try