bazi/gsb4j

Init error

Closed this issue · 2 comments

I'm using this in Kotlin, but there is init error. I checked that my secret passed successfully via System.getProperty("api.key").
Environment is a GCP Cloud Workstation instance which uses default IntelliJ IDEA config.

code
fun main()
{
        val sb=object{
                private val gsb4j: Gsb4j = Gsb4j.bootstrap()
                private val api= gsb4j.getApiClient(SafeBrowsingApi.Type.LOOKUP_API) //There was also error when I use UPDATE_API.
                fun isURLSafe(url: String): String = api.check(url).threatType.name
         }
        println(sb.isURLSafe(""))
        readLine()
}
log
Feb 03, 2023 4:09:59 PM com.google.inject.internal.MessageProcessor visit
INFO: An exception was caught and reported. Message: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2781e022
java.lang.IllegalStateException: Unable to load cache item
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:79)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:291)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:258)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:207)
	at com.google.inject.internal.ProviderMethod.create(ProviderMethod.java:69)
	at com.google.inject.internal.ProviderMethodsModule.createProviderMethod(ProviderMethodsModule.java:272)
	at com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:116)
	at com.google.inject.internal.ProviderMethodsModule.configure(ProviderMethodsModule.java:100)
	at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)
	at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:353)
	at com.google.inject.spi.Elements.getElements(Elements.java:103)
	at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:137)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at kg.net.bazi.gsb4j.Gsb4j.bootstrap(Gsb4j.java:90)
	at MainKt$main$sb$1.<init>(main.kt:17)
	at MainKt.main(main.kt:16)
	at MainKt.main(main.kt)
Caused by: java.lang.ExceptionInInitializerError
	at com.google.inject.internal.cglib.core.$DuplicatesPredicate.evaluate(DuplicatesPredicate.java:104)
	at com.google.inject.internal.cglib.core.$CollectionUtils.filter(CollectionUtils.java:52)
	at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:69)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:77)
	at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call(LoadingCache.java:54)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:61)
	... 20 more
Caused by: com.google.inject.internal.cglib.core.$CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2781e022
	at com.google.inject.internal.cglib.core.$ReflectUtils.defineClass(ReflectUtils.java:464)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call(LoadingCache.java:54)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:61)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:291)
	at com.google.inject.internal.cglib.core.$KeyFactory$Generator.create(KeyFactory.java:221)
	at com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:174)
	at com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:157)
	at com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:149)
	at com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:145)
	at com.google.inject.internal.cglib.core.$MethodWrapper.<clinit>(MethodWrapper.java:23)
	... 31 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2781e022
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:61)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
	at com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:52)
	at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:67)
	... 28 more

Exception in thread "main" com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2055)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3966)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3989)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4950)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4956)
	at com.google.inject.internal.FailableCache.get(FailableCache.java:51)
	at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:48)
	at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:155)
	at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:595)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:932)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:852)
	at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:291)
	at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:222)
	at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:938)
	at com.google.inject.internal.BoundProviderFactory.notify(BoundProviderFactory.java:47)
	at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:60)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at kg.net.bazi.gsb4j.Gsb4j.bootstrap(Gsb4j.java:90)
	at MainKt$main$sb$1.<init>(main.kt:17)
	at MainKt.main(main.kt:16)
	at MainKt.main(main.kt)
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2055)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3966)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3989)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4950)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4956)
	at com.google.inject.internal.FailableCache.get(FailableCache.java:51)
	at com.google.inject.internal.MembersInjectorStore.get(MembersInjectorStore.java:65)
	at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:74)
	at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
	at com.google.inject.internal.FailableCache$1.load(FailableCache.java:40)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3533)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2282)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2159)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
	... 22 more
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2055)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3966)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3989)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4950)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4956)
	at com.google.inject.internal.FailableCache.get(FailableCache.java:51)
	at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:48)
	at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:155)
	at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:595)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:932)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:852)
	at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:291)
	at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:222)
	at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:938)
	at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:48)
	at com.google.inject.internal.InjectorImpl.createImplementedByBinding(InjectorImpl.java:806)
	at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:696)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:930)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:852)
	at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:291)
	at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:222)
	at com.google.inject.internal.SingleFieldInjector.<init>(SingleFieldInjector.java:39)
	at com.google.inject.internal.MembersInjectorStore.getInjectors(MembersInjectorStore.java:126)
	at com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:93)
	at com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:36)
	at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:45)
	at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:41)
	at com.google.inject.internal.FailableCache$1.load(FailableCache.java:40)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3533)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2282)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2159)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
	... 37 more
Caused by: java.lang.IllegalStateException: Unable to load cache item
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:79)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:291)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:258)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:207)
	at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:49)
	at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:156)
	at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:92)
	at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
	at com.google.inject.internal.FailableCache$1.load(FailableCache.java:40)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3533)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2282)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2159)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
	... 68 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper
	at com.google.inject.internal.cglib.core.$DuplicatesPredicate.evaluate(DuplicatesPredicate.java:104)
	at com.google.inject.internal.cglib.core.$CollectionUtils.filter(CollectionUtils.java:52)
	at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:69)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:77)
	at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call(LoadingCache.java:54)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:61)
	... 85 more

Process finished with exit code 1

  • Gsb4j version: 1.0.6
  • Java version (output of java -version): 17.0.5
  • Kotlin version (in build.gradle.kts): 1.7.10

Got fixed after downgrade JDK to 1.8(there is NPE, but in my code).

Tested JDKs:
image

  • 1.8
  • 11
  • 13
  • 15
  • 17
  • 18