changeset 102:90b918cbf888

add JavaLib.privateAccess git-svn-id: https://luan-java.googlecode.com/svn/trunk@103 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 18 Jun 2013 02:46:24 +0000
parents 8ebcccca13ab
children c6c0aed1dbec
files src/luan/lib/JavaLib.java
diffstat 1 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
diff -r 8ebcccca13ab -r 90b918cbf888 src/luan/lib/JavaLib.java
--- a/src/luan/lib/JavaLib.java	Mon Jun 10 23:07:25 2013 +0000
+++ b/src/luan/lib/JavaLib.java	Tue Jun 18 02:46:24 2013 +0000
@@ -214,6 +214,7 @@
 		}
 	}
 
+	public static boolean privateAccess = false;
 	private static Map<Class,Map<String,List<Member>>> memberMap = new HashMap<Class,Map<String,List<Member>>>();
 
 	private static synchronized List<Member> getMembers(Class cls,String name) {
@@ -236,8 +237,6 @@
 				}
 				List<Member> list = new ArrayList<Member>();
 				clsMap.put(s,list);
-				list = new ArrayList<Member>();
-				clsMap.put(s,list);
 				list.add(field);
 			}
 			for( Method method : cls.getMethods() ) {
@@ -249,6 +248,29 @@
 				}
 				list.add(method);
 			}
+			if( privateAccess ) {
+				for( Method method : cls.getDeclaredMethods() ) {
+					String s = method.getName();
+					List<Member> list = clsMap.get(s);
+					if( list == null ) {
+						list = new ArrayList<Member>();
+						clsMap.put(s,list);
+					} else if( !(list.get(0) instanceof Method) )
+						continue;
+					if( !list.contains(method) ) {
+						list.add(method);
+					}
+				}
+				for( Field field : cls.getDeclaredFields() ) {
+					String s = field.getName();
+					List<Member> list = clsMap.get(s);
+					if( list == null ) {
+						list = new ArrayList<Member>();
+						clsMap.put(s,list);
+						list.add(field);
+					}
+				}
+			}
 			for( List<Member> members : clsMap.values() ) {
 				for( Member m : members ) {
 					if( m instanceof AccessibleObject )