龙心客栈

来源: BlogBus 原始链接: http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=318272 存档链接: https://web.archive.org/web/20040913200000id_/http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=318272


龙心客栈 一个讨论j2ee技术以及畅谈程序人生的地方,一个有共同兴趣和爱好的朋友相聚的乐园。 <<<学习java | 首页 | a trick about 'How to update multiple value in collection' on Struts>>> How to visit those methods which are not public? 时间: 2004-08-09 Today I met a question when I developed Execute Architecture,I need invoke a method 'test()' of a class A,but that method is 'protect',and my class isn't extends class A.what shall I do?Draft a class extends class A?I didn't want to add a class just for a method,my way is as follows: //If there is an instance 'a' of class A, Class c=a.getClass(); Method m=c.getDeclaredMethod("test",new Class[] {}); m.setAccessible(true); Object obj=m.invoke(a,null); then I got what I want.if there is a secruity manager,we should draft: ReflectPermission ref=new ReflectPermission("suppressAccessChecks"); dragonet 发表于 2004-08-09 19:17 引用(Trackback0) 评论 It's written all by youself?nice! especially in English. you can express yourself in English thoroughly. Very good, learn from you... steve_gu ( ) 发表于 2004-08-18 10:48 I hava a question about setAccessible. what's the range of the exxcute of this method. when and where the field or method will resume its access control. wangy ( ) 发表于 2004-08-21 16:21 I am not too clear,I will do some tests when I have time.But I think it's only useful for reflect object m. dragonet ( dragonet.blogbus.com ) 发表于 2004-08-23 19:04 发表评论 最后更新 log4j synthetically How to estimate a trick about 'How to update multiple value in collection' on Struts How to visit those methods which are not public? 学习java 八卦1: 瑜珈 Analysis Mechanism 关联类 关于培训的看法 一个小小的技巧,不知swing何时能这样?