example-code-2e/11-pythonic-obj/private/no_respect.py
2021-02-14 20:28:07 -03:00

20 lines
490 B
Python

#!/usr/bin/env jython
# NOTE: Jython is still Python 2.7 in late2020
"""
In the Jython registry file there is this line:
python.security.respectJavaAccessibility = true
Set this to false and Jython provides access to non-public
fields, methods, and constructors of Java objects.
"""
import Confidential
message = Confidential('top secret text')
for name in dir(message):
attr = getattr(message, name)
if not callable(attr): # non-methods only
print name + '\t=', attr