From 2753c59573bf353e3729cf24c769d79b1705ae91 Mon Sep 17 00:00:00 2001 From: Benson Margulies Date: Thu, 30 Apr 2015 16:24:27 -0400 Subject: [PATCH] Make lists work like Python list containers. --- jnius/reflect.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jnius/reflect.py b/jnius/reflect.py index ceaaa9d..2e0f1f5 100644 --- a/jnius/reflect.py +++ b/jnius/reflect.py @@ -215,6 +215,12 @@ def autoclass(clsname): classDict[name] = JavaMultipleMethod(signatures) + for iclass in c.getInterfaces(): + if iclass.getName() == 'java.util.List': + classDict['__getitem__'] = lambda self, index: self.get(index) + classDict['__len__'] = lambda self: self.size() + break + for field in c.getFields(): static = Modifier.isStatic(field.getModifiers()) sig = get_signature(field.getType())