Mercurial Hosting > luan
changeset 71:5a93129995e1
handle conflicting java member names
git-svn-id: https://luan-java.googlecode.com/svn/trunk@72 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sat, 02 Feb 2013 18:14:44 +0000 |
parents | 59431bb8d0bf |
children | cd9dbd7477ca |
files | src/luan/lib/JavaLib.java |
diffstat | 1 files changed, 19 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/lib/JavaLib.java Wed Jan 30 22:28:03 2013 +0000 +++ b/src/luan/lib/JavaLib.java Sat Feb 02 18:14:44 2013 +0000 @@ -122,10 +122,6 @@ private static Object member(Object obj,List<Member> members) throws LuanException { try { - for( Member m : members ) { - if( m instanceof AccessibleObject ) - ((AccessibleObject)m).setAccessible(true); - } if( members.size()==1 ) { Member member = members.get(0); if( member instanceof Static ) { @@ -203,22 +199,10 @@ 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); - if( list == null ) { - list = new ArrayList<Member>(); - clsMap.put(s,list); - } + List<Member> list = new ArrayList<Member>(); + clsMap.put(s,list); list.add(new Static(c)); } for( Field field : cls.getFields() ) { @@ -229,13 +213,27 @@ } catch(NoSuchFieldException e) { throw new RuntimeException(e); } - List<Member> list = clsMap.get(s); - if( list != null ) - throw new RuntimeException("can't add field '"+s+"' to "+cls+" because these are already defined: "+list); + 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() ) { + String s = method.getName(); + List<Member> list = clsMap.get(s); + if( list == null || !(list.get(0) instanceof Method) ) { + list = new ArrayList<Member>(); + clsMap.put(s,list); + } + list.add(method); + } + for( List<Member> members : clsMap.values() ) { + for( Member m : members ) { + if( m instanceof AccessibleObject ) + ((AccessibleObject)m).setAccessible(true); + } + } memberMap.put(cls,clsMap); } List<Member> rtn = clsMap.get(name);