FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
example-code/09-pythonic-obj/private/Expose.java at master · ChingweiYu/example-code · GitHub
ChingweiYu
/
example-code
Public
forked from
fluentpython/example-code
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
example-code
/
09-pythonic-obj
/
private
/
Expose.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (23 loc) · 790 Bytes
Breadcrumbs
example-code
/
09-pythonic-obj
/
private
/
Expose.java
Copy path
File metadata and controls
25 lines (23 loc) · 790 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import
java
.
lang
.
reflect
.
Field
;
public
class
Expose
{
public
static
void
main
(
String
[]
args
) {
Confidential
message
=
new
Confidential
(
"top secret text"
);
Field
secretField
=
null
;
try
{
secretField
=
Confidential
.
class
.
getDeclaredField
(
"secret"
);
}
catch
(
NoSuchFieldException
e
) {
System
.
err
.
println
(
e
);
System
.
exit
(
1
);
}
secretField
.
setAccessible
(
true
);
// break the lock!
try
{
String
wasHidden
= (
String
)
secretField
.
get
(
message
);
System
.
out
.
println
(
"message.secret = "
+
wasHidden
);
}
catch
(
IllegalAccessException
e
) {
// this will not happen after setAcessible(true)
System
.
err
.
println
(
e
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL