Fork me on GitHub
#graalvm
<
2022-05-07
>
Benjamin11:05:38

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

Benjamin11:05:14

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

borkdude11:05:37

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

Benjamin11:05:53

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

borkdude11:05:26

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

Benjamin11:05:09

"--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

borkdude11:05:35

you probably should avoid doing that

Benjamin11:05:13

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

borkdude11:05:21

yes, hence the "caching"

Benjamin11:05:53

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

borkdude11:05:20

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

Benjamin11:05:52

oh yes I'll to go into there 😛

Benjamin11:05:07

thamnks thanks bro

Benjamin13:05:44

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

Benjamin13:05:39

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/

Benjamin15:05:13

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 😅

borkdude15:05:53

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

borkdude15:05:12

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