Alien Quote by Brian Goetz
““From the perspective of a class C, an alien method is one whose behavior is not fully specified by C. This includes methods in other classes as well as overrideable methods (neither private nor final) in C itself. Passing an object to an alien method must also be considered publishing that object. Since you can’t know what code will actually be invoked, you don’t know that the alien method won’t publish the object or retain a reference to it that might later be used from another thread.””
About This Quote
Source Article: Java Concurrency in Practice, 2006
An alien method’s behavior is unspecified, making it unsafe to pass objects because they may be published or retained, leading to thread‑safety risks.
In simple terms: Unsafe to share objects with unknown methods.
Avoid passing objects to unknown code.
Themes
Mood
Type
When to use this quote
- code reviews
- secure coding guidelines
- multithreaded testing
Key Concepts
Questions to Reflect On
- How can you verify method safety?
- What design patterns mitigate these risks?
May limit flexibility in API usage.