[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [glassfish-dev] Need help - About MethodHandles.defineClass Behavior
|
- From: "sawamura.hiroki@xxxxxxxxxxx" <sawamura.hiroki@xxxxxxxxxxx>
- Date: Wed, 18 Mar 2020 02:04:28 +0000
- Accept-language: ja-JP, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fujitsu.com; dmarc=pass action=none header.from=fujitsu.com; dkim=pass header.d=fujitsu.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nZu72B9nRjFW6MvW9uAPAx6olrmBsXOdg9kvjLNci5A=; b=X+O+cBhhu7snB5Mx4MmmbC5zmcCiB/VCKkwE47HdAWlZCsY3/zWmC3N915gH3h1xtsMlF5I2dk/Dsdb1Vx23tHOS/6U2iL8mfhUmAuiBHGC+4d7d8W/n/yuZjQxqCfOBU6gugv/GT7BtAEef9gog3E8kcgeRICpmfNc+UEBrD8W+YPWXAxEfcNmvpdDPeujzcXHu2J5Cfi10R+KE0PNSU/kpzLHpioi11c6ll23Z0b8KLgYTHjmt6ekvQ2s7GjQW6ChUMTvzgGtCEI8Kfk2I7hHZ6SrsIdfhHBjk9Kj/+uKfFcgNU88N/MksXluUukMb7YFn9kdhOsWk79RXElCfXg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N2Awnai/VJq+pKv6AOGGJ07zLEoZmZr6z2qKWYBRwkqaaGtfx1eK7X3EP92/Dn2GprRtX68UTE0eIS9AXpnBnichP4VKN6EpsldkY1xCtauB/v2DFXjDnZiKGJpP7Ww6PweQ73wut4g4vMyeTbLlEhFk/i25sayucCRUYxwl1I4aW2OYUAAFiqIhQOMniHHsDahR8p03jcu+BMJ116tNNMjf5I56TMwjldF+axDGdtrr+jha+rvhof+rOdBbXc1i8k3kFZwMi9Ie1eKiT97QAyhzWur/U5+HmNedLO89DkQ6ZFHwUCHj/bVFynpC25H3E6XST8EYoXHpqG9Yx2E15A==
- Delivered-to: glassfish-dev@xxxxxxxxxxx
- Ironport-sdr: X/9jC+ZORG/RDCgp/1WS2HG+WU08YzaOrp7uBU0cGOzxrjhPM8uke2OCmsRNtc4uhMUP37rwIJ uiwzi28U4lrsrTLthhefyC/Fq8eUXIbpZIL7MsLWGMsG9bXE2cDX4nQmldsnjvIZSK/jCeFiU5 M2jRkeBXfNbN/Nk5F5Smb7BbMvx24bfWxBGE6inyGzljlYxfmWNvPQaZO56aAhfqlsaqpAbZpF 8fhZMBrbVNJTAzG3nKGo3TCqddt5BpYLj02jNQDcR76tnGbZ9Cy9f/+iloWNvr6sV30LXIwel0 h40=
- List-archive: <https://www.eclipse.org/mailman/private/glassfish-dev>
- List-help: <mailto:glassfish-dev-request@eclipse.org?subject=help>
- List-subscribe: <https://www.eclipse.org/mailman/listinfo/glassfish-dev>, <mailto:glassfish-dev-request@eclipse.org?subject=subscribe>
- List-unsubscribe: <https://www.eclipse.org/mailman/options/glassfish-dev>, <mailto:glassfish-dev-request@eclipse.org?subject=unsubscribe>
- Thread-index: AdX8wWZHe/LhvleyRM+k84Q5xJqCOQAAjwWAAAFs4lA=
- Thread-topic: [glassfish-dev] Need help - About MethodHandles.defineClass Behavior
Thank you for your prompt reply. Yes, but the defineClass method looks like it defines InitialGroupInfoService$_InitialGIS_DynamicStub.class in the same package (com.sun.corba.ee.impl.folb) as InitialGroupInfoService$InitialGIS.class. In this case, what kind of causes can be considered...?
-----Original Message-----
From: glassfish-dev-bounces@xxxxxxxxxxx <glassfish-dev-bounces@xxxxxxxxxxx> On Behalf Of Russell Gold
Sent: Wednesday, March 18, 2020 10:22 AM
To: glassfish developer discussions <glassfish-dev@xxxxxxxxxxx>
Subject: Re: [glassfish-dev] Need help - About MethodHandles.defineClass Behavior
In JDK11, the rules for defining classes have changed. One major change is that you cannot define a new class in an arbitrary package; you need to have another class to which you have access, that is in that package. There should be two defineClass methods, now, only one of which works in JDK11, and you have to follow the rules when using it. That means that you need to rewrite any existing calls.
> On Mar 17, 2020, at 9:13 PM, sawamura.hiroki@xxxxxxxxxxx wrote:
>
> Hi,
>
> I'm trying to get devtests to run on JDK 11, but I'm having trouble with the following issues.
> And now I'm looking for a hint or a clue to a solution... Does anyone have any idea?
>
> ■summary
> As part of JDK 11 support, the process of orb-gmbal-pfl defineClass(*) has changed.
> And when running devtests of glassfish on JDK 11, this method produces the following error:.
> ```
> [2020-03-16T13:13:01.042+0900] [glassfish 5.1] [SEVERE] []
> [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=45
> _ThreadName=admin-listener(1)] [timeMillis: 1584331981042]
> [levelValue: 1000] [[ Exception while invoking class
> org.glassfish.ejb.startup.EjbDeployer load method
> java.lang.RuntimeException: EJB Container initialization error
> (snip)
> Caused by: java.lang.IllegalArgumentException: Class not in same package as lookup class
> at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:955)
> at
> org.glassfish.pfl.basic.reflection.Bridge.defineClass(Bridge.java:148)
> (snip)
> ```
> However, when I checked the arguments, the classBytes being defined is the same package as the existing class anchorClass.
> This error occurs when deploying glassfish/lib/install/applications/mejb.jar, not when deploying a simple EJB app.
>
> (*) orb-gmbal-pfl:/pfl-basic/src/main/java11/org/glassfish/pfl/basic/reflection/Bridge.java
>
> https://urldefense.com/v3/__https://github.com/eclipse-ee4j/orb-gmbal-
> pfl/pull/22__;!!GqivPVa7Brio!NMMd505Lfe1nAAmIWPSyDaaTU7psgTfIc2IX0qkgA
> _VcANufANFxx_SYh6kQlvnu_w$
> ```
> @Override
> public Class<?> defineClass(Class<?> anchorClass, String className, byte[] classBytes) {
> try {
> MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(anchorClass, MethodHandles.lookup())
> .dropLookupMode(MethodHandles.Lookup.PRIVATE);
> return lookup.defineClass(classBytes);
> } catch (IllegalAccessException e) {
> throw new RuntimeException("Unable to define class ", e);
> }
> }
> ```
>
> ■when
> running devtests (5.1.0-run-with-JDK11 branch):
> - ejb_group_3
> - cdi_all
>
> (more specific) asadmin deploy
> glassfish/lib/install/applications/mejb.jar
>
> ■arguments when this error occurs
> anchorClass:
> anchorClass.toGenericString() -> "public abstract static interface com.sun.corba.ee.impl.folb.InitialGroupInfoService$InitialGIS"
> className:
> "com.sun.corba.ee.impl.folb.InitialGroupInfoService$_InitialGIS_DynamicStub"
> classBytes:
> ```
> # javap classBytes.class
> Compiled from "com/sun/corba/ee/impl/folb/InitialGroupInfoService$_InitialGIS_DynamicStub.java"
> public class
> com.sun.corba.ee.impl.folb.InitialGroupInfoService$_InitialGIS_Dynamic
> Stub extends
> com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase
> implements
> com.sun.corba.ee.impl.folb.InitialGroupInfoService$InitialGIS {
> public
> com.sun.corba.ee.impl.folb.InitialGroupInfoService$_InitialGIS_Dynamic
> Stub(); public java.util.List getClusterInstanceInfo(); } ```
>
> ■Stacktrace(server.log)
> ```
> [2020-03-16T13:13:01.041+0900] [glassfish 5.1] [SEVERE] []
> [javax.enterprise.resource.corba] [tid: _ThreadID=45
> _ThreadName=admin-listener(1)] [timeMillis: 1584331981041]
> [levelValue: 1000] [[ iiop.createreference_exception]]
>
> [2020-03-16T13:13:01.042+0900] [glassfish 5.1] [SEVERE] []
> [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=45
> _ThreadName=admin-listener(1)] [timeMillis: 1584331981042]
> [levelValue: 1000] [[ Exception while invoking class
> org.glassfish.ejb.startup.EjbDeployer load method
> java.lang.RuntimeException: EJB Container initialization error
> at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:210)
> at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:267)
> at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:75)
> at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:182)
> at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:289)
> at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:472)
> at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:195)
> at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:467)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:516)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:512)
> at java.base/java.security.AccessController.doPrivileged(Native Method)
> at java.base/javax.security.auth.Subject.doAs(Subject.java:361)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:511)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:542)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:534)
> at java.base/java.security.AccessController.doPrivileged(Native Method)
> at java.base/javax.security.auth.Subject.doAs(Subject.java:361)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:533)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1441)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:86)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1823)
> at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1699)
> at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:384)
> at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:211)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
> at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
> at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
> at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
> at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
> at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)
> at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)
> at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)
> at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253)
> at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
> at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
> at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
> at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
> at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
> at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
> at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232)
> at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:679)
> at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:353)
> at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:150)
> at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:155)
> at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439)
> at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
> at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
> at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
> at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
> at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
> at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
> at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
> at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
> at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
> at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
> at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:515)
> at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
> at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
> at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
> at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
> at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
> at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
> at java.base/java.lang.Thread.run(Thread.java:834)
> Caused by: java.lang.RuntimeException: Unable to create reference
> at org.glassfish.enterprise.iiop.impl.POARemoteReferenceFactory.createRef(POARemoteReferenceFactory.java:398)
> at org.glassfish.enterprise.iiop.impl.POARemoteReferenceFactory.createHomeReference(POARemoteReferenceFactory.java:351)
> at com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1306)
> at com.sun.ejb.containers.StatelessSessionContainer.initializeHome(StatelessSessionContainer.java:166)
> at com.sun.ejb.containers.StatelessContainerFactory.createContainer(StatelessContainerFactory.java:39)
> at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:198)
> ... 66 more
> Caused by: java.lang.IllegalArgumentException: Class not in same package as lookup class
> at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:955)
> at org.glassfish.pfl.basic.reflection.Bridge.defineClass(Bridge.java:148)
> at org.glassfish.pfl.dynamic.codegen.impl.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:57)
> at org.glassfish.pfl.dynamic.codegen.spi.Wrapper._generate(Wrapper.java:1069)
> at org.glassfish.pfl.dynamic.codegen.spi.Wrapper._generate(Wrapper.java:1040)
> at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenProxyCreator.create(CodegenProxyCreator.java:217)
> at com.sun.corba.ee.impl.presentation.rmi.codegen.StubFactoryCodegenImpl.createStubClass(StubFactoryCodegenImpl.java:71)
> at com.sun.corba.ee.impl.presentation.rmi.codegen.StubFactoryCodegenImpl.createStubClass(StubFactoryCodegenImpl.java:65)
> at com.sun.corba.ee.impl.presentation.rmi.codegen.StubFactoryCodegenImpl.lambda$getStubClass$0(StubFactoryCodegenImpl.java:48)
> at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
> at com.sun.corba.ee.impl.presentation.rmi.codegen.StubFactoryCodegenImpl.getStubClass(StubFactoryCodegenImpl.java:48)
> at com.sun.corba.ee.impl.presentation.rmi.codegen.StubFactoryCodegenImpl.makeStub(StubFactoryCodegenImpl.java:75)
> at org.glassfish.enterprise.iiop.impl.POARemoteReferenceFactory.createRef(POARemoteReferenceFactory.java:388)
> ... 71 more
> ]]
> ```
>
> Thanks,
> Hiroki
> _______________________________________________
> glassfish-dev mailing list
> glassfish-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit
> https://urldefense.com/v3/__https://www.eclipse.org/mailman/listinfo/g
> lassfish-dev__;!!GqivPVa7Brio!NMMd505Lfe1nAAmIWPSyDaaTU7psgTfIc2IX0qkg
> A_VcANufANFxx_SYh6ll_acTlw$
_______________________________________________
glassfish-dev mailing list
glassfish-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/glassfish-dev