org.adoptopenjdk.jitwatch.model.Task Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jitwatch-jarscan-maven-plugin Show documentation
Show all versions of jitwatch-jarscan-maven-plugin Show documentation
A Maven plugin that scans the project artifact and its dependencies for methods that cannot be inlined by the JIT
compiler. It uses the JarScan utility from the JITWatch project to do that.
See https://github.com/AdoptOpenJDK/jitwatch .
/*
* Copyright (c) 2013, 2014 Chris Newland.
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/
package org.adoptopenjdk.jitwatch.model;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.C_SPACE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.DEBUG_LOGGING_PARSE_DICTIONARY;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_COMMA;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_DOT;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_OPEN_PARENTHESES;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_SLASH;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_SPACE;
import java.util.Map;
import org.adoptopenjdk.jitwatch.core.JITWatchConstants;
import org.adoptopenjdk.jitwatch.util.ParseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Task extends Tag
{
private static final Logger logger = LoggerFactory.getLogger(Task.class);
private IParseDictionary parseDictionary;
private CompilerName compiler;
public Task(String name, Map attrs, boolean selfClosing, CompilerName compiler)
{
super(name, attrs, selfClosing);
this.compiler = compiler;
parseDictionary = new ParseDictionary();
}
public CompilerName getCompiler()
{
return compiler;
}
public IParseDictionary getParseDictionary()
{
return parseDictionary;
}
public void addDictionaryType(String type, Tag tag)
{
if (DEBUG_LOGGING_PARSE_DICTIONARY)
{
logger.debug("Adding type: {}", type);
}
parseDictionary.setType(type, tag);
}
public void addDictionaryMethod(String method, Tag tag)
{
if (DEBUG_LOGGING_PARSE_DICTIONARY)
{
logger.debug("Adding method: {}", method);
}
parseDictionary.setMethod(method, tag);
}
public void addDictionaryKlass(String klass, Tag tag)
{
if (DEBUG_LOGGING_PARSE_DICTIONARY)
{
logger.debug("Adding klass: {}", klass);
}
parseDictionary.setKlass(klass, tag);
}
public String decodeParseMethod(String method)
{
StringBuilder builder = new StringBuilder();
Tag methodTag = parseDictionary.getMethod(method);
String returnTypeID = methodTag.getAttribute(JITWatchConstants.ATTR_RETURN);
String args = methodTag.getAttribute(JITWatchConstants.ATTR_ARGUMENTS);
String methodName = methodTag.getAttribute(JITWatchConstants.ATTR_NAME);
String klassId = methodTag.getAttribute(JITWatchConstants.ATTR_HOLDER);
Tag klassTag = parseDictionary.getKlass(klassId);
String klassName = klassTag.getAttribute(JITWatchConstants.ATTR_NAME);
klassName = klassName.replace(S_SLASH, S_DOT);
builder.append(" ");
return builder.toString();
}
private String getTypeOrKlass(String id)
{
Tag typeTag = parseDictionary.getType(id);
String result = null;
if (typeTag == null)
{
Tag klassTag = parseDictionary.getKlass(id);
if (klassTag != null)
{
result = klassTag.getAttribute(JITWatchConstants.ATTR_NAME);
result = result.replace(S_SLASH, S_DOT);
}
}
else
{
result = typeTag.getAttribute(JITWatchConstants.ATTR_NAME);
}
if (result == null)
{
result = "???"; // further understanding required!
}
else
{
result = ParseUtil.expandParameterType(result);
}
return result;
}
}