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 8845713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:48:04+00:00 2026-06-14T11:48:04+00:00

In the source code of com.sun.org.apache.xerces.internal.impl.XMLScanner at line 183 and 186 183 protected final

  • 0

In the source code of
com.sun.org.apache.xerces.internal.impl.XMLScanner at line 183 and 186

183    protected final static String fVersionSymbol = "version".intern();

186    protected final static String fEncodingSymbol = "encoding".intern();

Why “version” and “encoding” are explicitly interned by using intern() while they are string literals and would get automatically interned?

  • 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-06-14T11:48:05+00:00Added an answer on June 14, 2026 at 11:48 am

    I’ve tracked down the change to revision 318617 in the Apache Xerces SVN Repository (this is the project where this XML parser was initially developed, as the package name suggests).

    The relevant part of the commit message is:

    Trying to improve the use of symbol tables. Many predefined Strings are
    added to symbol tables every time the parser is reset. For small documents,
    this would be a significant cost. Now since we call String#intern for Strings
    in the symbol table, it’s sufficient to use String#intern for those predefined
    symbols. This only needs to be performed once.

    As you noted, the .intern() should not be necessary (and should have no visible effect) on a conforming JVM implementation.

    My guess is that

    • either the author was not aware of the fact that string literals will always be interned
    • or it was a conscious decision to ward against a misbehaving JVM implementation

    In the second case I’d expect some note of that in a comment or in the comment message, however.

    One side-effect of that .intern() call is that initializers are no longer constant expressions and the fields will not be inlined by other classes referencing them.That will ensure that the class XMLScanner is loaded and its field read. I don’t think this is relevant here, however.

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

Sidebar

Related Questions

I'm reading some source code at https://github.com/plataformatec/devise and found that line of code: class_eval
I received this source code: http://www.sbbic.org/split.zip under the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0 It came
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
you can view full source code here dpaste.com/hold/167199 Error: delete() takes exactly 2 arguments
This is the complete source code: http://www.sendspace.com/file/lwxpyf I have a problem with a JSF
I download the latest source code from here: http://aspnetwebstack.codeplex.com/SourceControl/list/changesets 1) add the system.web.mvc project
I've been poking through the source code for Reddit (https://github.com/reddit/reddit/wiki) for the past few
I'm trying include this barcode source code Stefanhafeneger - Barcode github.com to my project
I've was studying on some source code from this link http://android-er.blogspot.com/2010/12/add-overlay-on-camera-preview.html what should i
If we look at the latest jQuery source at http://code.jquery.com/jquery-latest.js we see the following:

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.