package com.njust.test.kemu2;

import java.lang.reflect.Field;

class RTest
{
    public String field1;
    
    String field2;
    
    private String field3;
}

public class ReflectionTest2
{
    public static void main(String[] args)
        throws Exception
    {
        RTest rTest = new RTest();
        
        Field field = RTest.class.getField("field1");
        field.set(rTest, "test1");
        System.out.println(field.get(rTest));
        
        field = RTest.class.getDeclaredField("field2");
        field.set(rTest, "test2");
        System.out.println(field.get(rTest));
        
        field = RTest.class.getDeclaredField("field3");
        //java.lang.IllegalAccessException
        //System.out.println(field.get(rTest));
        //java.lang.IllegalAccessException
        //field.set(rTest, "test3");
    }
}

@@ -57,16 +57,103 @@
 Field;%0A%0A
+/**%0A * 1.public,protected%E7%9A%84%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5%E8%AE%BF%E9%97%AE%E5%88%B0%0A * 2.private%E9%BB%98%E8%AE%A4%E4%B8%8D%E8%83%BD%E8%AE%BF%E9%97%AE%EF%BC%9B%E4%BD%86%E6%98%AF%E5%8F%AF%E4%BB%A5%E8%AE%BE%E7%BD%AEsetAccessible(true)%E4%B9%8B%E5%90%8E%E8%AE%BF%E9%97%AE%0A */%0A
 class RT
@@ -182,16 +182,29 @@
 g field1
+ = %22default1%22
 ;%0A    %0A 
@@ -219,16 +219,29 @@
 g field2
+ = %22default2%22
 ;%0A    %0A 
@@ -268,12 +268,96 @@
 eld3
-;%0A%7D%0A
+ = %22default3%22;%0A%7D%0A%0A/**%0A * read1:test1%0A * read2:test2%0A * read3:default3%0A * read3:test3%0A */
 %0Apub
@@ -610,32 +610,43 @@
 tem.out.println(
+%22read1:%22 + 
 field.get(rTest)
@@ -767,32 +767,43 @@
 tem.out.println(
+%22read2:%22 + 
 field.get(rTest)
@@ -866,24 +866,42 @@
 (%22field3%22);%0A
+        //%E4%B8%8D%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5%E8%AE%BF%E9%97%AE%0A
         //ja
@@ -1055,20 +1055,242 @@
 , %22test3%22);%0A
+        %0A        //setAccessible%E5%90%8E%E5%8F%AF%E4%BB%A5%E8%AE%BF%E9%97%AE%0A        field.setAccessible(true);%0A        System.out.println(%22read3:%22 + field.get(rTest));%0A        field.set(rTest, %22test3%22);%0A        System.out.println(%22read3:%22 + field.get(rTest));%0A
     %7D%0A%7D%0A

Update ReflectionTest2.java