Mercurial Hosting > luan
comparison core/src/luan/modules/JavaLuan.java @ 277:8ac3eaf8ecd9
fix security
git-svn-id: https://luan-java.googlecode.com/svn/trunk@278 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 21 Nov 2014 05:39:46 +0000 |
parents | 9e0d4452e649 |
children | 899253043270 |
comparison
equal
deleted
inserted
replaced
276:e5a0dd95f3e7 | 277:8ac3eaf8ecd9 |
---|---|
27 | 27 |
28 public final class JavaLuan { | 28 public final class JavaLuan { |
29 | 29 |
30 public static final LuanFunction LOADER = new LuanFunction() { | 30 public static final LuanFunction LOADER = new LuanFunction() { |
31 @Override public Object call(LuanState luan,Object[] args) throws LuanException { | 31 @Override public Object call(LuanState luan,Object[] args) throws LuanException { |
32 if( PackageLuan.is_blocked(luan,"Java") ) | |
33 throw luan.exception("Java is blocked"); | |
34 LuanTable module = Luan.newTable(); | 32 LuanTable module = Luan.newTable(); |
35 try { | 33 try { |
36 module.put( "block", new LuanJavaFunction(JavaLuan.class.getMethod("block",LuanState.class),null) ); | |
37 module.put( "class", new LuanJavaFunction(JavaLuan.class.getMethod("getClass",LuanState.class,String.class),null) ); | 34 module.put( "class", new LuanJavaFunction(JavaLuan.class.getMethod("getClass",LuanState.class,String.class),null) ); |
38 add( module, "proxy", LuanState.class, Static.class, LuanTable.class, Object.class ); | 35 add( module, "proxy", LuanState.class, Static.class, LuanTable.class, Object.class ); |
39 } catch(NoSuchMethodException e) { | 36 } catch(NoSuchMethodException e) { |
40 throw new RuntimeException(e); | 37 throw new RuntimeException(e); |
41 } | 38 } |
65 try { | 62 try { |
66 t.put( method, new LuanJavaFunction(JavaLuan.class.getMethod(method,parameterTypes),null) ); | 63 t.put( method, new LuanJavaFunction(JavaLuan.class.getMethod(method,parameterTypes),null) ); |
67 } catch(NoSuchMethodException e) { | 64 } catch(NoSuchMethodException e) { |
68 throw new RuntimeException(e); | 65 throw new RuntimeException(e); |
69 } | 66 } |
70 } | |
71 | |
72 public static void block(LuanState luan) { | |
73 PackageLuan.block(luan,"Java"); | |
74 } | 67 } |
75 | 68 |
76 public static Object __index(LuanState luan,Object obj,Object key) throws LuanException { | 69 public static Object __index(LuanState luan,Object obj,Object key) throws LuanException { |
77 if( obj instanceof Static ) { | 70 if( obj instanceof Static ) { |
78 if( key instanceof String ) { | 71 if( key instanceof String ) { |