Java Code Examples for jdk.internal.dynalink.support.NameCodec#encode()
The following examples show how to use
jdk.internal.dynalink.support.NameCodec#encode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Compiler.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private String safeSourceName() { String baseName = new File(source.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (!env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } // ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char. // While ASM accepts such escapes for method names, field names, it enforces Java identifier // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_' // rather than safe encoding using '\'. final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 2
Source File: Compiler.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static String safeSourceName(final ScriptEnvironment env, final CodeInstaller<ScriptEnvironment> installer, final Source source) { String baseName = new File(source.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (!env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } // ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char. // While ASM accepts such escapes for method names, field names, it enforces Java identifier // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_' // rather than safe encoding using '\'. final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 3
Source File: Compiler.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private String safeSourceName() { String baseName = new File(source.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (!env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } // ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char. // While ASM accepts such escapes for method names, field names, it enforces Java identifier // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_' // rather than safe encoding using '\'. final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 4
Source File: Compiler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private String safeSourceName() { String baseName = new File(source.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (!env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } // ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char. // While ASM accepts such escapes for method names, field names, it enforces Java identifier // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_' // rather than safe encoding using '\'. final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 5
Source File: Compiler.java From hottub with GNU General Public License v2.0 | 6 votes |
private String safeSourceName() { String baseName = new File(source.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (!env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } // ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char. // While ASM accepts such escapes for method names, field names, it enforces Java identifier // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_' // rather than safe encoding using '\'. final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 6
Source File: Compiler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private String safeSourceName(final Source src) { String baseName = new File(src.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (! env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } final String mangled = NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 7
Source File: Compiler.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private String safeSourceName(final Source src) { String baseName = new File(src.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (! env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } final String mangled = NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 8
Source File: Compiler.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
private String safeSourceName() { String baseName = new File(source.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (!env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } // ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char. // While ASM accepts such escapes for method names, field names, it enforces Java identifier // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_' // rather than safe encoding using '\'. final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 9
Source File: Compiler.java From nashorn with GNU General Public License v2.0 | 6 votes |
private String safeSourceName(final Source src) { String baseName = new File(src.getName()).getName(); final int index = baseName.lastIndexOf(".js"); if (index != -1) { baseName = baseName.substring(0, index); } baseName = baseName.replace('.', '_').replace('-', '_'); if (! env._loader_per_compile) { baseName = baseName + installer.getUniqueScriptId(); } final String mangled = NameCodec.encode(baseName); return mangled != null ? mangled : baseName; }
Example 10
Source File: Parser.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * PropertyAssignment : * PropertyName : AssignmentExpression * get PropertyName ( ) { FunctionBody } * set PropertyName ( PropertySetParameterList ) { FunctionBody } * * PropertySetParameterList : * Identifier * * PropertyName : * IdentifierName * StringLiteral * NumericLiteral * * See 11.1.5 * * Parse an object literal property. * @return Property or reference node. */ private PropertyNode propertyAssignment() { // Capture firstToken. final long propertyToken = token; FunctionNode functionNode; PropertyKey propertyName; if (type == IDENT) { // Get IDENT. final String ident = (String)expectValue(IDENT); if (type != COLON) { final long getSetToken = propertyToken; switch (ident) { case "get": final PropertyKey getIdent = propertyName(); final String getterName = getIdent.getPropertyName(); final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, NameCodec.encode("get " + getterName)); expect(LPAREN); expect(RPAREN); functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER); return new PropertyNode(propertyToken, finish, getIdent, null, functionNode, null); case "set": final PropertyKey setIdent = propertyName(); final String setterName = setIdent.getPropertyName(); final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, NameCodec.encode("set " + setterName)); expect(LPAREN); final IdentNode argIdent = getIdent(); verifyStrictIdent(argIdent, "setter argument"); expect(RPAREN); List<IdentNode> parameters = new ArrayList<>(); parameters.add(argIdent); functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER); return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode); default: break; } } propertyName = new IdentNode(propertyToken, finish, ident).setIsPropertyName(); } else { propertyName = propertyName(); } expect(COLON); return new PropertyNode(propertyToken, finish, propertyName, assignmentExpression(false), null, null); }
Example 11
Source File: Parser.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * PropertyAssignment : * PropertyName : AssignmentExpression * get PropertyName ( ) { FunctionBody } * set PropertyName ( PropertySetParameterList ) { FunctionBody } * * PropertySetParameterList : * Identifier * * PropertyName : * IdentifierName * StringLiteral * NumericLiteral * * See 11.1.5 * * Parse an object literal property. * @return Property or reference node. */ private PropertyNode propertyAssignment() { // Capture firstToken. final long propertyToken = token; FunctionNode functionNode; PropertyKey propertyName; if (type == IDENT) { // Get IDENT. final String ident = (String)expectValue(IDENT); if (type != COLON) { final long getSetToken = propertyToken; switch (ident) { case "get": final PropertyKey getIdent = propertyName(); final String getterName = getIdent.getPropertyName(); final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, NameCodec.encode("get " + getterName)); expect(LPAREN); expect(RPAREN); functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER); return new PropertyNode(propertyToken, finish, getIdent, null, functionNode, null); case "set": final PropertyKey setIdent = propertyName(); final String setterName = setIdent.getPropertyName(); final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, NameCodec.encode("set " + setterName)); expect(LPAREN); final IdentNode argIdent = getIdent(); verifyStrictIdent(argIdent, "setter argument"); expect(RPAREN); List<IdentNode> parameters = new ArrayList<>(); parameters.add(argIdent); functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER); return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode); default: break; } } propertyName = new IdentNode(propertyToken, finish, ident).setIsPropertyName(); } else { propertyName = propertyName(); } expect(COLON); return new PropertyNode(propertyToken, finish, propertyName, assignmentExpression(false), null, null); }
Example 12
Source File: Parser.java From nashorn with GNU General Public License v2.0 | 4 votes |
/** * PropertyAssignment : * PropertyName : AssignmentExpression * get PropertyName ( ) { FunctionBody } * set PropertyName ( PropertySetParameterList ) { FunctionBody } * * PropertySetParameterList : * Identifier * * PropertyName : * IdentifierName * StringLiteral * NumericLiteral * * See 11.1.5 * * Parse an object literal property. * @return Property or reference node. */ private PropertyNode propertyAssignment() { // Capture firstToken. final long propertyToken = token; FunctionNode functionNode; PropertyKey propertyName; if (type == IDENT) { // Get IDENT. final String ident = (String)expectValue(IDENT); if (type != COLON) { final long getSetToken = token; switch (ident) { case "get": final PropertyKey getIdent = propertyName(); final String getterName = getIdent.getPropertyName(); final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + NameCodec.encode(getterName)); expect(LPAREN); expect(RPAREN); functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER); return new PropertyNode(propertyToken, finish, getIdent, null, functionNode, null); case "set": final PropertyKey setIdent = propertyName(); final String setterName = setIdent.getPropertyName(); final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + NameCodec.encode(setterName)); expect(LPAREN); final IdentNode argIdent = getIdent(); verifyStrictIdent(argIdent, "setter argument"); expect(RPAREN); List<IdentNode> parameters = new ArrayList<>(); parameters.add(argIdent); functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER); return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode); default: break; } } propertyName = new IdentNode(propertyToken, finish, ident).setIsPropertyName(); } else { propertyName = propertyName(); } expect(COLON); return new PropertyNode(propertyToken, finish, propertyName, assignmentExpression(false), null, null); }