m*p 发帖数: 1331 | 1 问题有点复杂。
有一个serialized的 java object, 属于class A, 可以load 进来,调用这个obj里面的
public method都没有问题。
现在需要访问class A 的 super class, class B 里面的一个protected variable,
不知道应该怎么处理?谢谢! |
M***0 发帖数: 1180 | 2 这个没办法,只有在class A里头能访问B里的protected variable |
m*p 发帖数: 1331 | 3 exactly that's the difficulty. is it possible to define another class and it
extends A, to access the protected var in B?
【在 M***0 的大作中提到】 : 这个没办法,只有在class A里头能访问B里的protected variable
|
M***0 发帖数: 1180 | 4 要是可以的话别人就不用玩了,游戏规则就是不给你访问的,哪里会有后门
不知道你能不能把你OP里说的那个java object序列化存储成你说的这个“another
class“类型
it
【在 m*p 的大作中提到】 : exactly that's the difficulty. is it possible to define another class and it : extends A, to access the protected var in B?
|
r*****l 发帖数: 2859 | 5 Try and you will get the answer.
it
【在 m*p 的大作中提到】 : exactly that's the difficulty. is it possible to define another class and it : extends A, to access the protected var in B?
|
r*****l 发帖数: 2859 | 6 You should be able to find a solution.
If you cannot find other way, use reflection.
【在 m*p 的大作中提到】 : 问题有点复杂。 : 有一个serialized的 java object, 属于class A, 可以load 进来,调用这个obj里面的 : public method都没有问题。 : 现在需要访问class A 的 super class, class B 里面的一个protected variable, : 不知道应该怎么处理?谢谢!
|
M***0 发帖数: 1180 | 7 长见识了,为什么reflection要提供这样的后门? 不应该啊
【在 r*****l 的大作中提到】 : You should be able to find a solution. : If you cannot find other way, use reflection.
|
m*p 发帖数: 1331 | 8 problem solved. :)
【在 r*****l 的大作中提到】 : You should be able to find a solution. : If you cannot find other way, use reflection.
|
b***i 发帖数: 3043 | 9 据说java serializable等技术需要这样的后门。
这些i好像对自动测试很有用,还有各类framework。
【在 M***0 的大作中提到】 : 长见识了,为什么reflection要提供这样的后门? 不应该啊
|
m*p 发帖数: 1331 | 10 yes, like spring.
【在 b***i 的大作中提到】 : 据说java serializable等技术需要这样的后门。 : 这些i好像对自动测试很有用,还有各类framework。
|
M***0 发帖数: 1180 | 11 是在AOP的时候吗? IOC好像不行吧,改成private还能inject?
【在 m*p 的大作中提到】 : yes, like spring.
|
a*******n 发帖数: 237 | 12 private 也能inject
【在 M***0 的大作中提到】 : 是在AOP的时候吗? IOC好像不行吧,改成private还能inject?
|
z****e 发帖数: 54598 | 13 你现在用spring还没有用@去autowire private变量?
【在 M***0 的大作中提到】 : 是在AOP的时候吗? IOC好像不行吧,改成private还能inject?
|