APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.jvm

public abstract Class StringConcat

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.tools.javac.jvm.StringConcat.Inline, com.sun.tools.javac.jvm.StringConcat.Indy
Imports
com.sun.tools.javac.code.*, .Symbol.MethodSymbol, com.sun.tools.javac.comp.Resolve, com.sun.tools.javac.jvm.PoolConstant.LoadableConstant, com.sun.tools.javac.jvm.Items.*, com.sun.tools.javac.tree.JCTree, .TreeInfo, .TreeMaker, com.sun.tools.javac.util.*, java.util.HashMap, .Map

This lowers the String concatenation to something that JVM can understand.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
StringConcat.Indy

Base class for indified concatenation bytecode flavors.

private static class
StringConcat.IndyConstants

Emits the invokedynamic call to JDK java.lang.invoke.StringConcatFactory.

private static class
StringConcat.IndyPlain

Emits the invokedynamic call to JDK java.lang.invoke.StringConcatFactory, without handling constants specially.

private static class
StringConcat.Inline

"Legacy" bytecode flavor: emit the StringBuilder.append chains for string concatenation.

Field Summary

Modifier and TypeField and Description
protected static final Context.Key<StringConcat>
protected final Gen
protected final TreeMaker
private static final int
MAX_INDY_CONCAT_ARG_SLOTS

Maximum number of slots for String Concat call.

protected final Names
protected final Resolve
protected final Map<Type, Symbol>
protected final Symtab
private static final char
private static final char
protected final Types

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private List<JCTree>
collect(JCTree tree, List<JCTree> res)

protected List<JCTree>
protected List<JCTree>
public static StringConcat
instance(Context context)

private static StringConcat
public abstract Items.Item
public abstract Items.Item
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

concatKeyback to summary
protected static final Context.Key<StringConcat> concatKey
genback to summary
protected final Gen gen
makeback to summary
protected final TreeMaker make
MAX_INDY_CONCAT_ARG_SLOTSback to summary
private static final int MAX_INDY_CONCAT_ARG_SLOTS

Maximum number of slots for String Concat call. JDK's StringConcatFactory does not support more than that.

namesback to summary
protected final Names names
rsback to summary
protected final Resolve rs
sbAppendsback to summary
protected final Map<Type, Symbol> sbAppends
symsback to summary
protected final Symtab syms
TAG_ARGback to summary
private static final char TAG_ARG
TAG_CONSTback to summary
private static final char TAG_CONST
typesback to summary
protected final Types types

Constructor Detail

StringConcatback to summary
protected StringConcat(Context context)
Annotations
@SuppressWarnings:this-escape

Method Detail

collectback to summary
private List<JCTree> collect(JCTree tree, List<JCTree> res)
collectAllback to summary
protected List<JCTree> collectAll(JCTree tree)
collectAllback to summary
protected List<JCTree> collectAll(JCTree.JCExpression lhs, JCTree.JCExpression rhs)
instanceback to summary
public static StringConcat instance(Context context)
makeConcatback to summary
private static StringConcat makeConcat(Context context)
makeConcatback to summary
public abstract Items.Item makeConcat(JCTree.JCAssignOp tree)
makeConcatback to summary
public abstract Items.Item makeConcat(JCTree.JCBinary tree)
com.sun.tools.javac.jvm back to summary

private abstract Class StringConcat.Indy

extends StringConcat
Class Inheritance
Known Direct Subclasses
com.sun.tools.javac.jvm.StringConcat.IndyPlain, com.sun.tools.javac.jvm.StringConcat.IndyConstants

Base class for indified concatenation bytecode flavors.

Field Summary

Inherited from com.sun.tools.javac.jvm.StringConcat:
concatKeygenmakenamesrssbAppendssymstypes

Constructor Summary

AccessConstructor and Description
public
Indy(Context context)

Method Summary

Modifier and TypeMethod and Description
protected abstract void
emit(JCDiagnostic.DiagnosticPosition pos, List<JCTree> args, boolean generateFirstArg, Type type)

public Items.Item
public Items.Item
protected boolean
shouldConvertToStringEagerly(Type argType)

Returns true if the argument should be converted to a string eagerly, to preserve possible side-effects.

protected List<List<JCTree>>
split(List<JCTree> args)

Peel the argument list into smaller chunks.

Inherited from com.sun.tools.javac.jvm.StringConcat:
collectAllcollectAllinstance

Constructor Detail

Indyback to summary
public Indy(Context context)

Method Detail

emitback to summary
protected abstract void emit(JCDiagnostic.DiagnosticPosition pos, List<JCTree> args, boolean generateFirstArg, Type type)
makeConcatback to summary
public Items.Item makeConcat(JCTree.JCAssignOp tree)

Implements abstract com.sun.tools.javac.jvm.StringConcat.makeConcat.

Annotations
@Override
makeConcatback to summary
public Items.Item makeConcat(JCTree.JCBinary tree)

Implements abstract com.sun.tools.javac.jvm.StringConcat.makeConcat.

Annotations
@Override
shouldConvertToStringEagerlyback to summary
protected boolean shouldConvertToStringEagerly(Type argType)

Returns true if the argument should be converted to a string eagerly, to preserve possible side-effects.

splitback to summary
protected List<List<JCTree>> split(List<JCTree> args)

Peel the argument list into smaller chunks.

com.sun.tools.javac.jvm back to summary

private final Class StringConcat.IndyConstants

extends Indy
Class Inheritance

Emits the invokedynamic call to JDK java.lang.invoke.StringConcatFactory. This code concatenates all known constants into the recipe, possibly escaping some constants separately. We also bypass empty strings, because they have no meaning at this level. This captures the Java language trick to force String concat with e.g. ("" + int)-like expression. Down here, we already know we are in String concat business, and do not require these markers.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
doCall(Type type, JCDiagnostic.DiagnosticPosition pos, String recipe, List<PoolConstant.LoadableConstant> staticArgs, List<Type> dynamicArgTypes)

Produce the actual invokedynamic call to StringConcatFactory

protected void
emit(JCDiagnostic.DiagnosticPosition pos, List<JCTree> args, boolean generateFirstArg, Type type)

Implements abstract com.sun.tools.javac.jvm.StringConcat.Indy.emit.

Inherited from com.sun.tools.javac.jvm.StringConcat.Indy:
makeConcatmakeConcatshouldConvertToStringEagerlysplit

Constructor Detail

IndyConstantsback to summary
public IndyConstants(Context context)

Method Detail

doCallback to summary
private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, String recipe, List<PoolConstant.LoadableConstant> staticArgs, List<Type> dynamicArgTypes)

Produce the actual invokedynamic call to StringConcatFactory

emitback to summary
protected void emit(JCDiagnostic.DiagnosticPosition pos, List<JCTree> args, boolean generateFirstArg, Type type)

Implements abstract com.sun.tools.javac.jvm.StringConcat.Indy.emit.

Annotations
@Override
com.sun.tools.javac.jvm back to summary

private Class StringConcat.IndyPlain

extends Indy
Class Inheritance

Emits the invokedynamic call to JDK java.lang.invoke.StringConcatFactory, without handling constants specially. We bypass empty strings, because they have no meaning at this level. This captures the Java language trick to force String concat with e.g. ("" + int)-like expression. Down here, we already know we are in String concat business, and do not require these markers.

Constructor Summary

AccessConstructor and Description
public
IndyPlain(Context context)

Method Summary

Modifier and TypeMethod and Description
private void
doCall(Type type, JCDiagnostic.DiagnosticPosition pos, List<Type> dynamicArgTypes)

Produce the actual invokedynamic call to StringConcatFactory

protected void
emit(JCDiagnostic.DiagnosticPosition pos, List<JCTree> args, boolean generateFirstArg, Type type)

Implements abstract com.sun.tools.javac.jvm.StringConcat.Indy.emit.

Emit the indy concat for all these arguments, possibly peeling along the way

Inherited from com.sun.tools.javac.jvm.StringConcat.Indy:
makeConcatmakeConcatshouldConvertToStringEagerlysplit

Constructor Detail

IndyPlainback to summary
public IndyPlain(Context context)

Method Detail

doCallback to summary
private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, List<Type> dynamicArgTypes)

Produce the actual invokedynamic call to StringConcatFactory

emitback to summary
protected void emit(JCDiagnostic.DiagnosticPosition pos, List<JCTree> args, boolean generateFirstArg, Type type)

Implements abstract com.sun.tools.javac.jvm.StringConcat.Indy.emit.

Emit the indy concat for all these arguments, possibly peeling along the way

com.sun.tools.javac.jvm back to summary

private Class StringConcat.Inline

extends StringConcat
Class Inheritance

"Legacy" bytecode flavor: emit the StringBuilder.append chains for string concatenation.

Field Summary

Inherited from com.sun.tools.javac.jvm.StringConcat:
concatKeygenmakenamesrssbAppendssymstypes

Constructor Summary

AccessConstructor and Description
public
Inline(Context context)

Method Summary

Modifier and TypeMethod and Description
private void
private void
public Items.Item
public Items.Item
private JCDiagnostic.DiagnosticPosition
Inherited from com.sun.tools.javac.jvm.StringConcat:
collectAllcollectAllinstance

Constructor Detail

Inlineback to summary
public Inline(Context context)

Method Detail

appendStringback to summary
private void appendString(JCTree tree)
builderToStringback to summary
private void builderToString(JCDiagnostic.DiagnosticPosition pos)
makeConcatback to summary
public Items.Item makeConcat(JCTree.JCAssignOp tree)

Implements abstract com.sun.tools.javac.jvm.StringConcat.makeConcat.

Annotations
@Override
makeConcatback to summary
public Items.Item makeConcat(JCTree.JCBinary tree)

Implements abstract com.sun.tools.javac.jvm.StringConcat.makeConcat.

Annotations
@Override
newStringBuilderback to summary
private JCDiagnostic.DiagnosticPosition newStringBuilder(JCTree tree)