sunhk commented on issue #10386:
URL: https://github.com/apache/dubbo/issues/10386#issuecomment-1214744412
Objenesis应该也是判断jvm提供商来调用底层逻辑,虽然没细看,但感觉应该可以,反正代码是能跑通的
```java
public class ReflectTest {
public static void main(String[] args) throws ClassNotFoundException,
NoSuchMethodException, InvocationTargetException, IllegalAccessException,
NoSuchFieldException {
Objenesis objenesis = new ObjenesisStd();
Class<?> clazz =
Class.forName("org.bson.types.ObjectId$SerializationProxy",false,ReflectTest.class.getClassLoader());
ObjectInstantiator<?> instantiator =
objenesis.getInstantiatorOf(clazz);
Object a = instantiator.newInstance();
System.out.println(a);
Field field = clazz.getDeclaredField("bytes");
field.setAccessible(true);
field.set(a,new byte[12]);
Method method = clazz.getDeclaredMethod("readResolve");
method.setAccessible(true);
Object result = method.invoke(a);
System.out.println(result);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]