diff src/luan/lib/JavaLib.java @ 58:d6c454b7f58c

make concat work with any type; improve JavaLib.getMembers(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@59 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 07 Jan 2013 00:18:35 +0000
parents c84274b18f0c
children a68ccb7aaa9c
line wrap: on
line diff
--- a/src/luan/lib/JavaLib.java	Sun Jan 06 19:17:56 2013 +0000
+++ b/src/luan/lib/JavaLib.java	Mon Jan 07 00:18:35 2013 +0000
@@ -150,6 +150,15 @@
 		Map<String,List<Member>> clsMap = memberMap.get(cls);
 		if( clsMap == null ) {
 			clsMap = new HashMap<String,List<Member>>();
+			for( Method method : cls.getMethods() ) {
+				String s = method.getName();
+				List<Member> list = clsMap.get(s);
+				if( list == null ) {
+					list = new ArrayList<Member>();
+					clsMap.put(s,list);
+				}
+				list.add(method);
+			}
 			for( Class c : cls.getClasses() ) {
 				String s = c.getSimpleName();
 				List<Member> list = clsMap.get(s);
@@ -161,22 +170,19 @@
 			}
 			for( Field field : cls.getFields() ) {
 				String s = field.getName();
+				try {
+					if( !cls.getField(s).equals(field) )
+						continue;  // not accessible
+				} catch(NoSuchFieldException e) {
+					throw new RuntimeException(e);
+				}
 				List<Member> list = clsMap.get(s);
-				if( list == null ) {
-					list = new ArrayList<Member>();
-					clsMap.put(s,list);
-				}
+				if( list != null )
+					throw new RuntimeException("can't add field '"+s+"' to "+cls+" because these are already defined: "+list);
+				list = new ArrayList<Member>();
+				clsMap.put(s,list);
 				list.add(field);
 			}
-			for( Method method : cls.getMethods() ) {
-				String s = method.getName();
-				List<Member> list = clsMap.get(s);
-				if( list == null ) {
-					list = new ArrayList<Member>();
-					clsMap.put(s,list);
-				}
-				list.add(method);
-			}
 			memberMap.put(cls,clsMap);
 		}
 		List<Member> rtn = clsMap.get(name);