Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:22:19+00:00 2026-05-26T20:22:19+00:00

As we all know javac inlines constants at compile time which can lead to

  • 0

As we all know javac inlines constants at compile time which can lead to interesting problems when only recompiling parts of an application and everyone here knows the usual solution to this (make it so that javac doesn’t understand it’s actually a compile time constant)

But if we look at the code in System.class of the oracle JDK we see the following:

public final static PrintStream out = null;

So presumably out is set by reflection or some other mechanism in the JVM initialization. But this leads to the question: Why isn’t out being inlined here? (at least I have never gotten a null pointer exception when using System.out.println()).

Does javac special case that scenario or is this actually handled by the language spec sensibly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:22:20+00:00Added an answer on May 26, 2026 at 8:22 pm

    There are multiple outcomes of static final construct. Literals might be inlined
    for instance static final int xxx = 1, as that’s clear but for instance static final int xxx = returnOne() may not be.

    Primitive types and String can be replaced with literals only, all other objects may not. Last but not least System.out/in violate JLS ( Once a final field has been initialized, it always contains the same value. ).

    Few ways to prevent inline: static final String xxx="xxx".intern(); or static final int yyy=123+return0(); since the evaluation may be performed only during runtime the javac will generate GETFIELD and not BIPUSH (for int).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that you can run almost all Java in Dalvik's VM that you
As you all know using java it is possible to create methods which require
As we all know, String is immutable in java. however, one can change it
As we all know Java program will start executing from the public static void
I know that Java enforce the programmer to list all exceptions that will be
I have a background of programming in Java and C++, so I know all
I know that in java that we use *(asterisk) to import all the contents
i know that the JDK consists of all java packages .But what does the
Does anybody know if there is a way using java to pass all the
As you maybe know, as Java language perspective all method in C# are final

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.