Unneeded interfaces removed
This commit is contained in:
+12
-2
@@ -18,6 +18,16 @@ package org.jetbrains.jet.preloading.instrumentation;
|
|||||||
|
|
||||||
import org.jetbrains.asm4.Type;
|
import org.jetbrains.asm4.Type;
|
||||||
|
|
||||||
interface FieldData extends MemberData {
|
class FieldData extends MemberData {
|
||||||
Type getRuntimeType();
|
|
||||||
|
private final Type runtimeType;
|
||||||
|
|
||||||
|
public FieldData(String declaringClass, String name, String desc, Type runtimeType) {
|
||||||
|
super(declaringClass, name, desc);
|
||||||
|
this.runtimeType = runtimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getRuntimeType() {
|
||||||
|
return runtimeType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.preloading.instrumentation;
|
|
||||||
|
|
||||||
import org.jetbrains.asm4.Type;
|
|
||||||
|
|
||||||
class FieldDataImpl extends MemberDataImpl implements FieldData {
|
|
||||||
|
|
||||||
private final Type runtimeType;
|
|
||||||
|
|
||||||
public FieldDataImpl(String declaringClass, String name, String desc, Type runtimeType) {
|
|
||||||
super(declaringClass, name, desc);
|
|
||||||
this.runtimeType = runtimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getRuntimeType() {
|
|
||||||
return runtimeType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -111,7 +111,7 @@ public class InterceptionInstrumenter {
|
|||||||
|
|
||||||
String nameFromAnnotation = annotation.methodName();
|
String nameFromAnnotation = annotation.methodName();
|
||||||
String methodName = nameFromAnnotation.isEmpty() ? field.getName() : nameFromAnnotation;
|
String methodName = nameFromAnnotation.isEmpty() ? field.getName() : nameFromAnnotation;
|
||||||
MethodInstrumenterImpl instrumenter = new MethodInstrumenterImpl(
|
MethodInstrumenter instrumenter = new MethodInstrumenter(
|
||||||
field.getDeclaringClass().getSimpleName() + "." + field.getName(),
|
field.getDeclaringClass().getSimpleName() + "." + field.getName(),
|
||||||
classPattern,
|
classPattern,
|
||||||
compilePattern(methodName),
|
compilePattern(methodName),
|
||||||
@@ -147,7 +147,7 @@ public class InterceptionInstrumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static FieldData getFieldData(Field field, Class<?> runtimeType) {
|
private static FieldData getFieldData(Field field, Class<?> runtimeType) {
|
||||||
return new FieldDataImpl(
|
return new FieldData(
|
||||||
Type.getInternalName(field.getDeclaringClass()),
|
Type.getInternalName(field.getDeclaringClass()),
|
||||||
field.getName(),
|
field.getName(),
|
||||||
Type.getDescriptor(field.getType()),
|
Type.getDescriptor(field.getType()),
|
||||||
@@ -188,7 +188,7 @@ public class InterceptionInstrumenter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new MethodDataImpl(
|
return new MethodData(
|
||||||
interceptorField,
|
interceptorField,
|
||||||
Type.getInternalName(method.getDeclaringClass()),
|
Type.getInternalName(method.getDeclaringClass()),
|
||||||
method.getName(),
|
method.getName(),
|
||||||
|
|||||||
+23
-4
@@ -16,8 +16,27 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.preloading.instrumentation;
|
package org.jetbrains.jet.preloading.instrumentation;
|
||||||
|
|
||||||
interface MemberData {
|
class MemberData {
|
||||||
String getDeclaringClass();
|
|
||||||
String getName();
|
private final String declaringClass;
|
||||||
String getDesc();
|
private final String name;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
public MemberData(String declaringClass, String name, String desc) {
|
||||||
|
this.declaringClass = declaringClass;
|
||||||
|
this.name = name;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeclaringClass() {
|
||||||
|
return declaringClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.preloading.instrumentation;
|
|
||||||
|
|
||||||
class MemberDataImpl implements MemberData {
|
|
||||||
|
|
||||||
private final String declaringClass;
|
|
||||||
private final String name;
|
|
||||||
private final String desc;
|
|
||||||
|
|
||||||
public MemberDataImpl(String declaringClass, String name, String desc) {
|
|
||||||
this.declaringClass = declaringClass;
|
|
||||||
this.name = name;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDeclaringClass() {
|
|
||||||
return declaringClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDesc() {
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+40
-10
@@ -16,18 +16,48 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.preloading.instrumentation;
|
package org.jetbrains.jet.preloading.instrumentation;
|
||||||
|
|
||||||
interface MethodData extends MemberData {
|
public class MethodData extends MemberData {
|
||||||
FieldData getOwnerField();
|
private final FieldData ownerField;
|
||||||
|
private final int thisParameterIndex;
|
||||||
|
private final int methodNameParameterIndex;
|
||||||
|
private final int methodDescParameterIndex;
|
||||||
|
private final int allArgsParameterIndex;
|
||||||
|
|
||||||
// -1 for no @This parameter
|
MethodData(
|
||||||
int getThisParameterIndex();
|
FieldData ownerField,
|
||||||
|
String declaringClass,
|
||||||
|
String name,
|
||||||
|
String desc,
|
||||||
|
int thisParameterIndex,
|
||||||
|
int methodNameParameterIndex,
|
||||||
|
int methodDescParameterIndex,
|
||||||
|
int allArgsParameterIndex
|
||||||
|
) {
|
||||||
|
super(declaringClass, name, desc);
|
||||||
|
this.ownerField = ownerField;
|
||||||
|
this.thisParameterIndex = thisParameterIndex;
|
||||||
|
this.methodNameParameterIndex = methodNameParameterIndex;
|
||||||
|
this.methodDescParameterIndex = methodDescParameterIndex;
|
||||||
|
this.allArgsParameterIndex = allArgsParameterIndex;
|
||||||
|
}
|
||||||
|
|
||||||
// -1 for no @MethodName
|
public FieldData getOwnerField() {
|
||||||
int getMethodNameParameterIndex();
|
return ownerField;
|
||||||
|
}
|
||||||
|
|
||||||
// -1 for no @MethodDesc
|
public int getThisParameterIndex() {
|
||||||
int getMethodDescParameterIndex();
|
return thisParameterIndex;
|
||||||
|
}
|
||||||
|
|
||||||
// -1 for no @AllArgs
|
public int getMethodNameParameterIndex() {
|
||||||
int getAllArgsParameterIndex();
|
return methodNameParameterIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMethodDescParameterIndex() {
|
||||||
|
return methodDescParameterIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAllArgsParameterIndex() {
|
||||||
|
return allArgsParameterIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-68
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.preloading.instrumentation;
|
|
||||||
|
|
||||||
public class MethodDataImpl extends MemberDataImpl implements MethodData {
|
|
||||||
private final FieldData ownerField;
|
|
||||||
private final int thisParameterIndex;
|
|
||||||
private final int methodNameParameterIndex;
|
|
||||||
private final int methodDescParameterIndex;
|
|
||||||
private final int allArgsParameterIndex;
|
|
||||||
|
|
||||||
MethodDataImpl(
|
|
||||||
FieldData ownerField,
|
|
||||||
String declaringClass,
|
|
||||||
String name,
|
|
||||||
String desc,
|
|
||||||
int thisParameterIndex,
|
|
||||||
int methodNameParameterIndex,
|
|
||||||
int methodDescParameterIndex,
|
|
||||||
int allArgsParameterIndex
|
|
||||||
) {
|
|
||||||
super(declaringClass, name, desc);
|
|
||||||
this.ownerField = ownerField;
|
|
||||||
this.thisParameterIndex = thisParameterIndex;
|
|
||||||
this.methodNameParameterIndex = methodNameParameterIndex;
|
|
||||||
this.methodDescParameterIndex = methodDescParameterIndex;
|
|
||||||
this.allArgsParameterIndex = allArgsParameterIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldData getOwnerField() {
|
|
||||||
return ownerField;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThisParameterIndex() {
|
|
||||||
return thisParameterIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMethodNameParameterIndex() {
|
|
||||||
return methodNameParameterIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMethodDescParameterIndex() {
|
|
||||||
return methodDescParameterIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAllArgsParameterIndex() {
|
|
||||||
return allArgsParameterIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+57
-7
@@ -17,17 +17,67 @@
|
|||||||
package org.jetbrains.jet.preloading.instrumentation;
|
package org.jetbrains.jet.preloading.instrumentation;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
interface MethodInstrumenter {
|
class MethodInstrumenter {
|
||||||
boolean isApplicable(String name, String desc);
|
private final String debugName;
|
||||||
|
private final Pattern classPattern;
|
||||||
|
private final Pattern namePattern;
|
||||||
|
private final Pattern descPattern;
|
||||||
|
private final boolean allowMultipleMatches;
|
||||||
|
private final List<MethodData> enterData;
|
||||||
|
private final List<MethodData> normalReturnData;
|
||||||
|
private final List<MethodData> exceptionData;
|
||||||
|
private final boolean logApplications;
|
||||||
|
|
||||||
List<MethodData> getNormalReturnData();
|
public MethodInstrumenter(
|
||||||
|
String debugName,
|
||||||
|
Pattern classPattern, Pattern namePattern,
|
||||||
|
Pattern descPattern,
|
||||||
|
boolean allowMultipleMatches,
|
||||||
|
List<MethodData> enterData,
|
||||||
|
List<MethodData> normalReturnData,
|
||||||
|
List<MethodData> exceptionData, boolean logApplications
|
||||||
|
) {
|
||||||
|
this.debugName = debugName;
|
||||||
|
this.classPattern = classPattern;
|
||||||
|
this.namePattern = namePattern;
|
||||||
|
this.descPattern = descPattern;
|
||||||
|
this.allowMultipleMatches = allowMultipleMatches;
|
||||||
|
this.enterData = enterData;
|
||||||
|
this.normalReturnData = normalReturnData;
|
||||||
|
this.exceptionData = exceptionData;
|
||||||
|
this.logApplications = logApplications;
|
||||||
|
}
|
||||||
|
|
||||||
List<MethodData> getExceptionData();
|
public boolean allowsMultipleMatches() {
|
||||||
|
return allowMultipleMatches;
|
||||||
|
}
|
||||||
|
|
||||||
List<MethodData> getEnterData();
|
public void reportApplication(String className, String methodName, String methodDesc) {
|
||||||
|
if (logApplications) {
|
||||||
|
System.out.println(toString() + " applied to " + className + ":" + methodName + methodDesc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean allowsMultipleMatches();
|
public boolean isApplicable(String name, String desc) {
|
||||||
|
return namePattern.matcher(name).matches() && descPattern.matcher(desc).matches();
|
||||||
|
}
|
||||||
|
|
||||||
void reportApplication(String className, String methodName, String methodDesc);
|
public List<MethodData> getEnterData() {
|
||||||
|
return enterData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MethodData> getNormalReturnData() {
|
||||||
|
return normalReturnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MethodData> getExceptionData() {
|
||||||
|
return exceptionData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return debugName + "[" + classPattern + ":" + namePattern + " " + descPattern + (allowMultipleMatches ? " multiple" : "") + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-89
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.preloading.instrumentation;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
class MethodInstrumenterImpl implements MethodInstrumenter {
|
|
||||||
private final String debugName;
|
|
||||||
private final Pattern classPattern;
|
|
||||||
private final Pattern namePattern;
|
|
||||||
private final Pattern descPattern;
|
|
||||||
private final boolean allowMultipleMatches;
|
|
||||||
private final List<MethodData> enterData;
|
|
||||||
private final List<MethodData> normalReturnData;
|
|
||||||
private final List<MethodData> exceptionData;
|
|
||||||
private final boolean logApplications;
|
|
||||||
|
|
||||||
public MethodInstrumenterImpl(
|
|
||||||
String debugName,
|
|
||||||
Pattern classPattern, Pattern namePattern,
|
|
||||||
Pattern descPattern,
|
|
||||||
boolean allowMultipleMatches,
|
|
||||||
List<MethodData> enterData,
|
|
||||||
List<MethodData> normalReturnData,
|
|
||||||
List<MethodData> exceptionData, boolean logApplications
|
|
||||||
) {
|
|
||||||
this.debugName = debugName;
|
|
||||||
this.classPattern = classPattern;
|
|
||||||
this.namePattern = namePattern;
|
|
||||||
this.descPattern = descPattern;
|
|
||||||
this.allowMultipleMatches = allowMultipleMatches;
|
|
||||||
this.enterData = enterData;
|
|
||||||
this.normalReturnData = normalReturnData;
|
|
||||||
this.exceptionData = exceptionData;
|
|
||||||
this.logApplications = logApplications;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean allowsMultipleMatches() {
|
|
||||||
return allowMultipleMatches;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reportApplication(String className, String methodName, String methodDesc) {
|
|
||||||
if (logApplications) {
|
|
||||||
System.out.println(toString() + " applied to " + className + ":" + methodName + methodDesc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isApplicable(String name, String desc) {
|
|
||||||
return namePattern.matcher(name).matches() && descPattern.matcher(desc).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MethodData> getEnterData() {
|
|
||||||
return enterData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MethodData> getNormalReturnData() {
|
|
||||||
return normalReturnData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MethodData> getExceptionData() {
|
|
||||||
return exceptionData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return debugName + "[" + classPattern + ":" + namePattern + " " + descPattern + (allowMultipleMatches ? " multiple" : "") + "]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user