History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QB-3979
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: U. Artie Eoff
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
QuickBuild

java.lang.reflect.InaccessibleObjectException

Created: 02/Jun/23 01:09 PM   Updated: 03/Jun/23 01:19 AM
Component/s: None
Affects Version/s: 13.0.18
Fix Version/s: 13.0.21

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Ubuntu Jammy


 Description  « Hide
We have a groovy script step in QB configuration like:

   groovy:
   import java.io.File;
   new File(configuration.workspaceDir, "changes.html").withWriter('utf-8') { writer ->
     writer.writeLine "<html><body><table>";
     ...
   }

It works fine since OpenJDK 11. However, after upgrade to OpenJDK 19, groovy script in QB throws exception:

java.lang.reflect.InaccessibleObjectException: Unable to make java.util.stream.ReferencePipeline$Head(java.util.function.Supplier,int,boolean) accessible: module java.base does not "opens java.util.stream" to unnamed module @c91cdc2
    at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
    at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:192)
    at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:185)
    at org.codehaus.groovy.reflection.CachedConstructor$1.run(CachedConstructor.java:41)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at org.codehaus.groovy.reflection.CachedConstructor.<init>(CachedConstructor.java:39)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:74)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:64)
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
    at org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:258)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:187)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:191)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:149)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:139)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:122)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:165)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:195)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:231)
    at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:747)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(CallSiteArray.java:109)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:150)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at script16856119001691618345306$_run_closure1.doCall(script16856119001691618345306.groovy:35)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
    at groovy.lang.Closure.call(Closure.java:415)
    at groovy.lang.Closure.call(Closure.java:428)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(DefaultGroovyMethods.java:17374)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(DefaultGroovyMethods.java:17245)
    at org.codehaus.groovy.runtime.dgm$959.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at script16856119001691618345306.run(script16856119001691618345306.groovy:30)
    at com.pmease.quickbuild.plugin.basis.BasisPlugin$33.evaluate(BasisPlugin.java:391)
    at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:316)
    at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:75)
    at com.pmease.quickbuild.plugin.basis.ScriptStep.run(ScriptStep.java:86)
    at com.pmease.quickbuild.plugin.basis.ScriptStep$$EnhancerByCGLIB$$489c487d.CGLIB$run$0(<generated>)
    at com.pmease.quickbuild.plugin.basis.ScriptStep$$EnhancerByCGLIB$$489c487d$$FastClassByCGLIB$$13e8a2fa.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:267)
    at com.pmease.quickbuild.plugin.basis.ScriptStep$$EnhancerByCGLIB$$489c487d.run(<generated>)
    at com.pmease.quickbuild.stepsupport.Step.doExecute(Step.java:677)
    at com.pmease.quickbuild.stepsupport.Step.execute(Step.java:577)
    at com.pmease.quickbuild.stepsupport.StepExecutionJob.executeStepAwareJob(StepExecutionJob.java:31)
    at com.pmease.quickbuild.stepsupport.StepAwareJob.executeBuildAwareJob(StepAwareJob.java:56)
    at com.pmease.quickbuild.BuildAwareJob.execute(BuildAwareJob.java:77)
    at com.pmease.quickbuild.grid.GridJob.run(GridJob.java:131)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1589)

The same issue also happens when upgrading to OpenJDK 17

We are able to workaround the issue by adding the following to the quickbuidl/conf/wrapper.conf file:

  wrapper.java.additional.35=--add-opens=java.base/java.util.stream=ALL-UNNAMED

...however, this modification is inconvenient and potentially error prone since we automate QB deployment.


 All   Comments   Work Log   Change History      Sort Order:
U. Artie Eoff [02/Jun/23 01:12 PM]
Ideally, the wrapper.conf modification would be included in the release so we don't have to do any manual modification to it.

U. Artie Eoff [02/Jun/23 01:20 PM]
Actually, the script error might come from a different spot... "pbs.stream().find", below. Here is the full groovy script for your reference:

    groovy:
    import java.io.File;
    import java.util.Set;
    import com.pmease.quickbuild.dependency.QuickbuildRepository;
    import com.pmease.quickbuild.plugin.basis.DummyRepository;
    def baseBuildDeps(b) {
        def result = [] as Set;
        if (b) {
            for (repository in b.repositories) {
                if (repository instanceof DummyRepository) {
                    continue;
                }
                if (repository instanceof QuickbuildRepository) {
                    for (info in repository.revision.value) {
                        result = result.plus(baseBuildDeps(system.buildManager.get(info.buildId)));
                    }
                } else {
                    result.add(repository.build);
                }
            }
        }
        return result;
    }
    def cbs = baseBuildDeps(build);
    def pbs = baseBuildDeps(build.previous);
    new File(configuration.workspaceDir, "changes.html").withWriter('utf-8') { writer ->
        writer.writeLine "<html><body><table>";
        writer.writeLine "<tr><td colspan=3 style='text-align:center;vertical-align:middle;font-weight:bold' bgcolor='#9dbfbf'>Changes</td></tr>";
        
        for (cb in cbs) {
            def pb = pbs.stream().find { it -> it.configuration.id == cb.configuration.id };
            
            // if there is a previous build dep and the previous build dep is not the same as
            // the current build dep, then capture all the changes since the previous build dep.
            if (pb && pb != cb) {
                it = system.buildManager.getNext(pb);
                while (it && it != cb) {
                    for (change in it.changes) {
                        writer.writeLine "<tr>";
                        writer.writeLine "<td style='vertical-align: top;'><a href='" + it.url + "'>" + it.configuration.name + "</a></td>";
                        writer.writeLine "<td style='vertical-align: top;'><pre>" + change.id.substring(0, 12) + "</pre></td>";
                        writer.writeLine "<td style='vertical-align: top;'><pre> - " + util.formatString(change.comment.readLines()[0]) + "</pre></td>";
                        writer.writeLine "</tr>";
                    }
                    it = system.buildManager.getNext(it);
                }
                
                for (change in cb.changes) {
                    writer.writeLine "<tr>";
                    writer.writeLine "<td style='vertical-align: top;'><a href='" + cb.url + "'>" + cb.configuration.name + "</a></td>";
                    writer.writeLine "<td style='vertical-align: top;'><pre>" + change.id.substring(0, 12) + "</pre></td>";
                    writer.writeLine "<td style='vertical-align: top;'><pre> - " + util.formatString(change.comment.readLines()[0]) + "</pre></td>";
                    writer.writeLine "</tr>";
                }
            }
        }
        writer.writeLine "</table></body></html>";
    }

Robin Shen [03/Jun/23 01:19 AM]
Thanks for the investigation. This has now been fixed in 13.0.21.