<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>Hmm, I guess I stand corrected.&nbsp; I still don't get where they are put though.&nbsp; The only output after a compile is the types for each java file compiled (and their internal types).&nbsp; There is no global place to store literal strings that I'm aware of.&nbsp; If what you have below refers only to runtime, then the performance issue is eliminated, but not the footprint issue.<br><br>John Verhaeg<br>Red Hat, Inc.<br>(314) 336-2950<br><br>----- "Randall Hauch" &lt;rhauch@redhat.com&gt; wrote:
<br>| <link href="/zimbra/css/msgview.css?v=080814121557" rel="stylesheet">Per the Java Language Spec (sect 3.10.5), at&nbsp;<a href="http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html" target="_blank">http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html</a>. &nbsp;Bold is mine:<div><br>| </div><div><div><b>- Literal strings within the same class (§8) in the same package (§7) represent references to the same String object (§4.3.1).</b></div><div><b>- Literal strings within different classes in the same package represent references to the same String object.</b></div><div><b>- Literal strings within different classes in different packages likewise represent references to the same String object.</b></div><div>- Strings computed by constant expressions (§15.28) are computed at compile time and then treated as if they were literals.</div><div>- Strings computed at run time are newly created and therefore distinct.</div><div>- The result of explicitly interning a computed string is the same string as any pre-existing literal string with the same contents.&nbsp;</div></div><div><br>| <div><div>On Oct 28, 2008, at 3:16 PM, Randall Hauch wrote:</div><br class="Apple-interchange-newline"><blockquote><div style="">| I don't believe you're right, at least for string literals available at compile-time. &nbsp;Those are all interned into the same bucket.<div><br>| <div><div>On Oct 28, 2008, at 2:38 PM, John Verhaeg wrote:</div><br class="Apple-interchange-newline"><blockquote><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><div><div style="font-family: 'Times New Roman'; font-size: 12pt; color: rgb(0, 0, 0);">| I believe your comments below are not entirely accurate.&nbsp; There is both a performance and footprint benefit to having such a constant, albeit small in either case.&nbsp; Java ensures a single entry for an empty string exists in a class's literal pool within the bytecode, but I don't know of any other internalization or special handling for this.&nbsp; Each class that uses the empty string would have its own bytecode to represent the literal empty string.&nbsp; The constant avoids both this and the instantiation of said string whenever the class itself is instantiated.<br>| <br>| I'd also argue that the EMPTY_STRING constant is more readable, although longer to type, than "".&nbsp; :-P<br>| <br>| John Verhaeg<br>| Red Hat, Inc.<br>| (314) 336-2950<br>| <br>| -----<span class="Apple-converted-space">&nbsp;</span><a href="mailto:dna-commits@lists.jboss.org" target="_blank">dna-commits@lists.jboss.org</a><span class="Apple-converted-space">&nbsp;</span>wrote:<span class="Apple-converted-space">&nbsp;</span><br>| | Author: rhauch<br>| | Date: 2008-10-28 15:21:10 -0400 (Tue, 28 Oct 2008)<br>| | New Revision: 594<br>| |<span class="Apple-converted-space">&nbsp;</span><br>| | Modified:<br>| | &nbsp;&nbsp; trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java<br>| | &nbsp;&nbsp; trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java<br>| | Log:<br>| | Removed the static constant for an empty string, as Java always interns all string literals such as "". &nbsp;So, there is no performance or efficiency benefit, and its simpler (if not shorter) to use "" rather than a constant.<br>| |<span class="Apple-converted-space">&nbsp;</span><br>| |<span class="Apple-converted-space">&nbsp;</span><br>| | Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java<br>| | ===================================================================<br>| | --- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008-10-28 17:55:47 UTC (rev 593)<br>| | +++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008-10-28 19:21:10 UTC (rev 594)<br>| | @@ -32,7 +32,6 @@<br>| | &nbsp;import org.jboss.dna.common.collection.ThreadSafeProblems;<br>| | &nbsp;import org.jboss.dna.common.i18n.I18n;<br>| | &nbsp;import org.jboss.dna.common.util.CheckArg;<br>| | -import org.jboss.dna.common.util.StringUtil;<br>| | &nbsp;<br>| | &nbsp;/**<br>| | &nbsp;&nbsp;* A basic progress monitor.<br>| | @@ -64,8 +63,8 @@<br>| | &nbsp;<br>| | &nbsp;&nbsp; &nbsp; public SimpleProgressMonitor( String activityName,<br>| | &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ProgressMonitor parentProgressMonitor ) {<br>| | - &nbsp; &nbsp; &nbsp; &nbsp;this.activityName = activityName == null ? StringUtil.EMPTY_STRING : activityName.trim();<br>| | - &nbsp; &nbsp; &nbsp; &nbsp;this.parentActivityName = parentProgressMonitor == null ? StringUtil.EMPTY_STRING : parentProgressMonitor.getActivityName();<br>| | + &nbsp; &nbsp; &nbsp; &nbsp;this.activityName = activityName == null ? "" : activityName.trim();<br>| | + &nbsp; &nbsp; &nbsp; &nbsp;this.parentActivityName = parentProgressMonitor == null ? "" : parentProgressMonitor.getActivityName();<br>| | &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; this.taskName = null;<br>| | &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; this.taskNameParams = null;<br>| | &nbsp;&nbsp; &nbsp; }<br>| |<span class="Apple-converted-space">&nbsp;</span><br>| | Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java<br>| | ===================================================================<br>| | --- trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008-10-28 17:55:47 UTC (rev 593)<br>| | +++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008-10-28 19:21:10 UTC (rev 594)<br>| | @@ -45,7 +45,6 @@<br>| | &nbsp;&nbsp;*/<br>| | &nbsp;public class StringUtil {<br>| | &nbsp;<br>| | - &nbsp; &nbsp;public static final String EMPTY_STRING = "";<br>| | &nbsp;&nbsp; &nbsp; public static final String[] EMPTY_STRING_ARRAY = new String[0];<br>| | &nbsp;&nbsp; &nbsp; private static final Pattern NORMALIZE_PATTERN = Pattern.compile("\\s+");<br>| | &nbsp;&nbsp; &nbsp; private static final Pattern PARAMETER_COUNT_PATTERN = Pattern.compile("\\{(\\d+)\\}");<br>| |<span class="Apple-converted-space">&nbsp;</span><br>| | _______________________________________________<br>| | dna-commits mailing list<br>| |<span class="Apple-converted-space">&nbsp;</span><a href="mailto:dna-commits@lists.jboss.org" target="_blank">dna-commits@lists.jboss.org</a><br>| |<span class="Apple-converted-space">&nbsp;</span><a href="https://lists.jboss.org/mailman/listinfo/dna-commits" target="_blank">https://lists.jboss.org/mailman/listinfo/dna-commits</a><br>| |</div>_______________________________________________<br>| dna-commits mailing list<br>| <a href="mailto:dna-commits@lists.jboss.org" target="_blank">dna-commits@lists.jboss.org</a><br>| <a href="https://lists.jboss.org/mailman/listinfo/dna-commits" target="_blank">https://lists.jboss.org/mailman/listinfo/dna-commits</a><br>| </div></span></blockquote></div><br>| </div></div>_______________________________________________<br>| dna-commits mailing list<br>| <a href="mailto:dna-commits@lists.jboss.org" target="_blank">dna-commits@lists.jboss.org</a><br>| <a href="https://lists.jboss.org/mailman/listinfo/dna-commits" target="_blank">https://lists.jboss.org/mailman/listinfo/dna-commits</a><br>| </blockquote></div><br>| </div></div></body></html>