The Artima Developer Community
Sponsored Link

Java Answers Forum
I want to run this program...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
park jung gyu

Posts: 1
Nickname: dalant19
Registered: Apr, 2005

I want to run this program... Posted: Apr 14, 2005 12:04 AM
Reply to this message Reply
Advertisement
import java.lang.reflect.*;

public class ReflectSecurity{
public static void main(String[] args){
try{

ReflectPermission rp = new ReflectPermission("suppressAccessChecks");

SecurityManager sm = System.getSecurityManager();

sm.checkPermission(rp);

TwoString ts = new TwoString("a", "b");

Field f = ts.getClass().getDeclaredField("m_s1");

f.setAccessible(true);

System.out.println(f.get(ts));

}
catch (Exception e){
e.printStackTrace();
}
}
}

I typed
"java -Djava.security.manager ReflectSecurity" to console.

This result is

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\reflection>java -Djava.security.m
anager ReflectSecurity
java.security.AccessControlException: access denied (java.lang.reflect.ReflectPe
rmission suppressAccessChecks)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at ReflectSecurity.main(ReflectSecurity.java:10)


======================
I think that the reason is a security problem.
please help me.

Topic: Accessing the function of a thread/runnable Previous Topic   Next Topic Topic: a problem about compareTo(Object rv)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use