scala.runtime.SymbolLiteral Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-library Show documentation
Show all versions of scala-library Show documentation
Standard library for the Scala Programming Language
package scala.runtime;
import java.lang.invoke.*;
public final class SymbolLiteral {
private SymbolLiteral() {
}
public static CallSite bootstrap(MethodHandles.Lookup lookup, String invokedName,
MethodType invokedType,
String value) throws Throwable {
ClassLoader classLoader = lookup.lookupClass().getClassLoader();
MethodType type = MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", classLoader);
Class symbolClass = Class.forName("scala.Symbol", false, classLoader);
MethodHandle factoryMethod = lookup.findStatic(symbolClass, "apply", type);
Object symbolValue = factoryMethod.invokeWithArguments(value);
return new ConstantCallSite(MethodHandles.constant(symbolClass, symbolValue));
}
}