from java.lang.reflect import Modifier import ObjetoSecreto oSecreto = ObjetoSecreto('senha super secreta') campos = ObjetoSecreto.getDeclaredFields() for campo in campos: # so campos privados! if Modifier.isPrivate(campo.getModifiers()): print campo campo.setAccessible(True) # arrombamos a porta print '\t', campo.getName(), '=', campo.get(oSecreto)
#!/usr/bin/env jython # NOTE: Jython is still Python 2.7 in late2020 from java.lang.reflect import Modifier import Confidential message = Confidential('top secret text') fields = Confidential.getDeclaredFields() for field in fields: # list private fields only if Modifier.isPrivate(field.getModifiers()): field.setAccessible(True) # break the lock print 'field:', field print '\t', field.getName(), '=', field.get(message)
from java.lang.reflect import Modifier import Confidential message = Confidential('top secret text') fields = Confidential.getDeclaredFields() for field in fields: # list private fields only if Modifier.isPrivate(field.getModifiers()): field.setAccessible(True) # break the lock print 'field:', field print '\t', field.getName(), '=', field.get(message)
from java.lang.reflect import Modifier import ObjetoSecreto oSecreto = ObjetoSecreto('senha super secreta') campos = ObjetoSecreto.getDeclaredFields() for campo in campos: if Modifier.isPrivate(campo.getModifiers()): # so campos privados! print campo campo.setAccessible(True) # arrombamos a porta print '\t', campo.getName(), '=', campo.get(oSecreto)