Skip to content

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…” quote by Brian Goetz
Download Open image
““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.””

Brian Goetz

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.

Key Takeaway

Avoid passing objects to unknown code.

Themes

software engineering concurrency security

Mood

analytical cautious

Type

technical educational

When to use this quote

  • code reviews
  • secure coding guidelines
  • multithreaded testing

Key Concepts

thread safety object publishing API design

Questions to Reflect On

  • How can you verify method safety?
  • What design patterns mitigate these risks?
A Different Perspective

May limit flexibility in API usage.

3.3 out of 5 (4 ratings)

More by Brian Goetz

Explore all 13 Brian Goetz quotes

More Alien quotes

Browse all 448 Alien quotes