Bug 1059

Summary: AUDIT use of intern for String constants and reference comparisons
Product: [JogAmp] Jogl Reporter: Harvey Harrison <harvey.harrison>
Component: coreAssignee: Harvey Harrison <harvey.harrison>
Status: IN_PROGRESS ---    
Severity: enhancement CC: sgothel
Priority: ---    
Version: 3.0.0   
Hardware: All   
OS: all   
Type: TASK SCM Refs:
ffde09410fb78c43bd45d6c5e62606789dced6eb
Workaround: ---

Description Harvey Harrison 2014-09-02 18:57:23 CEST
String constants appearing in class files are implicitly interned by the VM at class load time.  As such, explicit calls to .intern() are unneeded for these strings, and they can be compared with explicit reference comparisons where we know a constant has been passed in.  Audit recent commits adding .intern() and look into whether further use of reference comparisons are safe.
Comment 1 Sven Gothel 2014-09-02 19:00:55 CEST
(In reply to comment #0)
> String constants appearing in class files are implicitly interned by the VM
> at class load time.  

hharrison: It's part of the bytecode standard
Comment 2 Sven Gothel 2014-09-02 19:28:12 CEST
hharrison: Class1 { public static final Sting foo = "some string";}
hharrison: Class2 { public string bar = Class1.foo; }
sgothel: I see no delta here, since assignment to 'foo' is done after [optional] operation
hharrison: As part of the bytecode of class2, the whole string "some string" is inlined, not a ref to Class1.foo
Comment 3 Sven Gothel 2014-09-02 19:29:59 CEST
Maybe you can add one test case validating the inlining and intern() magic
in TestGLProfile01NEWT, i.e.
  assertEqual("GL2", GLProfile.GL2)

The test is in it's own jar, as GLProfile is.
Comment 4 Sven Gothel 2014-09-03 15:44:09 CEST
ffde09410fb78c43bd45d6c5e62606789dced6eb

Bug 1059 _and_ version-compat breackage of 
commit c78ceb642d0ef5bb5bf27ff8ff1495175ee2e983
    
    Commit c78ceb642d0ef5bb5bf27ff8ff1495175ee2e983 changed:
      -    public static final String GL4   = "GL4";
      +    public static final String GL4   = "GL4".intern();
    
    which is identified by semver as incompatible,
    due to Bug 1059 (no more inlining of interned string references).

+++

Further '.intern()' removals must happen for version 2.3.0 
to not break backward binary compatibility.
Comment 5 Sven Gothel 2014-09-03 17:14:00 CEST
(In reply to comment #4)
> 
> Further '.intern()' removals must happen for version 2.3.0 
> to not break backward binary compatibility.

Moved from 2.2.1 -> 2.3.0:
  <https://jogamp.org/wiki/index.php/SW_Tracking_Report_Objectives_for_the_release_2.3.0>
Comment 6 Sven Gothel 2015-01-27 15:06:18 CET
if we have no activity here anymore, I may close this bug 'in a while'.
Comment 7 Sven Gothel 2020-01-05 01:12:07 CET
keep it open as a reminder