由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - access java parent class protected variable question
相关主题
java 依赖注入和反射是必须掌握的吗?java的东西好多
j2ee without EJB问一个java的面试题 (转载)
看Spring真是头大谁深入解答一下Java的Reflection机制
新手学习java spring, hibernate或者struts的问题请问一个serialize class object下载运行的问题
c++熟手如何学习Java直到能够参与开发企业级应用?interesting "protect" behavior
关于struts和spring的几个疑问新手问题 -- dynamic variable and dynamic functions.
spring到底有什么好处?spring frame work question
不明白Spring Framework很正常how to copy an Object?
相关话题的讨论汇总
话题: class话题: variable话题: protected话题: java话题: access
进入Java版参与讨论
1 (共1页)
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?
1 (共1页)
进入Java版参与讨论
相关主题
how to copy an Object?c++熟手如何学习Java直到能够参与开发企业级应用?
Is it possible to get Class object for T from a generic class? (下列空档,是否可填)关于struts和spring的几个疑问
请教:怎么把synchronize的method改成用thread 但thread safe呢?spring到底有什么好处?
Why inner classes can access only local final variables?不明白Spring Framework很正常
java 依赖注入和反射是必须掌握的吗?java的东西好多
j2ee without EJB问一个java的面试题 (转载)
看Spring真是头大谁深入解答一下Java的Reflection机制
新手学习java spring, hibernate或者struts的问题请问一个serialize class object下载运行的问题
相关话题的讨论汇总
话题: class话题: variable话题: protected话题: java话题: access