throw new IOException("can not load resource [" + resource + "] from classpath");
}
BufferedReader r = new BufferedReader(new InputStreamReader(in, MethodDatabase.UTF_8));
db.getUserDefinedWaveConfigFiles().add(resource);
String l = null;
ClassEntry ce = null;
LazyClassEntry lce = null;
FuzzyLazyClassEntry flce = null;
int lc = 0;
String clz = null;
while ((l = r.readLine()) != null) {
lc++;
l = l.trim();
if (l.startsWith("class:")) {
lce = null;
flce = null;
clz = l.substring("class:".length());
ce = db.getClasses().get(clz);
if (ce == null) {
ce = buildClassEntryFamily(db, clz);
if (ce == null) {
db.warn("file %s line %d : not found class: %s", resource , lc, clz);
ce = null;
continue;
}
}
}else if (l.startsWith("lazyclass:")) {
clz = l.substring("lazyclass:".length());
ce = null;
flce = null;
lce = db.getLazyClasses().get(clz);
if (lce == null) {
db.getLazyClasses().put(clz, lce = new LazyClassEntry(resource));
}
}else if (l.startsWith("fuzzyclass:")) {
clz = l.substring("fuzzyclass:".length());
ce = null;
lce = null;
flce = new FuzzyLazyClassEntry(Pattern.compile(clz), resource);
db.getFuzzlyLazyClasses().add(flce);
}else if (l.startsWith("retransform:")) {
db.getRetransformedClasses().add(l.substring("retransform:".length()).trim());
ce = null;
lce = null;
flce = null;
}else if (l.startsWith("filter:")) {
db.getFilters().add(l.substring("filter:".length()).trim());
ce = null;
lce = null;
flce = null;
}else if (l.length() == 0 || (ce == null && lce == null && flce == null) || l.charAt(0) == '#'){
continue;
}else {
String[] ma = l.split(":");
String m = ma[0];
Integer st = MethodDatabase.SUSPEND_NORMAL;
if (ma.length > 1) {
if (MethodDatabase.SUSPEND_NORMAL_STR.equals(ma[1])) {
st = MethodDatabase.SUSPEND_NORMAL;
}else if (MethodDatabase.SUSPEND_NONE_STR.equals(ma[1])) {
st = MethodDatabase.SUSPEND_NONE;
}else if (MethodDatabase.SUSPEND_JUST_MARK_STR.equals(ma[1])) {
st = MethodDatabase.SUSPEND_JUST_MARK;
}else if (MethodDatabase.SUSPEND_BLOCKING_STR.equals(ma[1])) {
st = MethodDatabase.SUSPEND_BLOCKING;
}else if (MethodDatabase.SUSPEND_FAMILY_STR.equals(ma[1])) {
st = MethodDatabase.SUSPEND_FAMILY;
}else if (MethodDatabase.SUSPEND_SKIP_STR.equals(ma[1])) {
st = MethodDatabase.SUSPEND_SKIP;
}else {
db.warn("file %s line %d : unknown suspend type: %s , we just set to 'normal'", resource , lc, ma[1]);
st = MethodDatabase.SUSPEND_NORMAL;
}
}
if (lce != null) {
Map<String, Integer> methods = lce.getMethods();
Integer ost = methods.get(m);
if (ost == null || st.intValue() > ost.intValue()) {
methods.put(m, st);
}else {
st = ost;
}
if (db.meetTraceTargetClassMethod(clz, m)) {
db.info("meet traced method %s.%s, suspend type = %s", clz, m, MethodDatabase.SUSPEND_TYPE_STRS[st]);
}
continue;
}else if (flce != null) {
Map<String, Integer> methods = flce.getMethods();
Integer ost = methods.get(m);
if (ost == null || st.intValue() > ost.intValue()) {
methods.put(m, st);
}else {
st = ost;
}
if (db.meetTraceTargetClassMethod(clz, m)) {
db.info("meet traced method %s.%s, suspend type = %s", clz, m, MethodDatabase.SUSPEND_TYPE_STRS[st]);
}
continue;
}
if (m.charAt(0) == '/') { // regex pattern
Pattern p = Pattern.compile(m.substring(1));
boolean matched = false;
for (Entry<String, Integer> me : ce.getMethods().entrySet()) {
if (p.matcher(me.getKey()).find()) {
me.setValue(st);
matched = true;
}
}
if (!matched) {
db.warn("file %s line %d : none of methods matched regex: %s ,ignored", resource , lc, m);
}
}else if (ce.getMethods().get(m) == null) {
db.warn("file %s line %d : unknown method: %s ,ignored", resource , lc, m);
continue;
}else {
Integer ost = ce.getMethods().get(m);
if (ost == null || st.intValue() > ost.intValue()) {
ce.set(m, st);
}else {
st = ost;
}
if (db.meetTraceTargetClassMethod(clz, m)) {
db.info("meet traced method %s.%s, suspend type = %s", clz, m, MethodDatabase.SUSPEND_TYPE_STRS[st]);