Skip to content

Commit 449dc4c

Browse files
author
Steve Salas
committed
Squashed 'bytefrog/' changes from 010e2ed..ed3fe53
ed3fe53 Avoid instrumenting complex constructors a5adfe9 Fix line level mapping arithmetic the right way 2c1b777 Fix line level mapping arithmetic 4c6b71b Implement JSP/mapped source support 407a310 Fix uninitialized stackmap reference exception 6510fc3 Don't repackage bytefrog dependencies 7508807 Update license header 2da38b5 Inject filter class immediately f05917d Fix jarjar path when referencing project git-subtree-dir: bytefrog git-subtree-split: ed3fe53a99f9d1b6e2c8eae92adc90d6db4467f6
1 parent 77de926 commit 449dc4c

File tree

62 files changed

+4274
-208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4274
-208
lines changed

build.sbt

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
val shared = Seq(
22
organization := "com.codedx",
3-
scalacOptions := List("-deprecation", "-unchecked", "-feature"),
3+
scalacOptions := Seq("-deprecation", "-unchecked", "-feature"),
44
scalaVersion := "2.12.4",
5-
javacOptions := List("-source", "1.7", "-target", "1.7", "-Xlint:-options", "-Xlint:unchecked")
5+
javacOptions := Seq("-source", "1.7", "-target", "1.7", "-Xlint:-options")
66
)
77

88
val javaOnly = Seq(
99
autoScalaLibrary := false,
1010
crossPaths := false
11-
// unmanagedSourceDirectories in Compile <<= (javaSource in Compile) { _ :: Nil }
11+
)
12+
13+
val javaWarnings = Seq(
14+
javacOptions ++= Seq("-Xlint:unchecked")
1215
)
1316

1417
val withTesting = Seq(
@@ -17,43 +20,45 @@ val withTesting = Seq(
1720
libraryDependencies += Dependencies.scalaMock
1821
)
1922

20-
lazy val RepackagedAsm = project
23+
lazy val Instrumentation = (project in file("instrumentation"))
24+
.dependsOn(SourceMapParser)
2125
.settings(
2226
shared,
2327
javaOnly,
24-
Repackager("asm", Dependencies.asm, Repackager.Rename("org.objectweb.asm.**", "com.codedx.bytefrog.thirdparty.asm.@1")).settings
25-
)
28+
javaWarnings,
29+
withTesting,
2630

27-
lazy val RepackagedMinlog = project
28-
.settings(
29-
shared,
30-
javaOnly,
31-
Repackager("minlog", Dependencies.minlog, Repackager.Rename("com.esotericsoftware.minlog.**", "com.codedx.bytefrog.thirdparty.minlog.@1")).settings
31+
libraryDependencies ++= Dependencies.asm,
32+
libraryDependencies += Dependencies.minlog
3233
)
3334

34-
lazy val Instrumentation = (project in file("instrumentation"))
35-
.dependsOn(RepackagedAsm)
35+
lazy val FilterInjector = (project in file("filter-injector"))
36+
.dependsOn(Util)
3637
.settings(
3738
shared,
3839
javaOnly,
39-
withTesting
40+
javaWarnings,
41+
42+
libraryDependencies ++= Dependencies.asm,
43+
libraryDependencies += Dependencies.minlog
4044
)
4145

42-
lazy val FilterInjector = (project in file("filter-injector"))
43-
.dependsOn(RepackagedAsm, RepackagedMinlog, Util)
46+
lazy val SourceMapParser = (project in file("sourcemap-parser"))
4447
.settings(
4548
shared,
4649
javaOnly
4750
)
4851

4952
lazy val Util = (project in file("util"))
50-
.dependsOn(RepackagedAsm, RepackagedMinlog)
5153
.settings(
5254
shared,
5355
javaOnly,
54-
withTesting
56+
javaWarnings,
57+
withTesting,
58+
59+
libraryDependencies ++= Dependencies.asm,
60+
libraryDependencies += Dependencies.minlog
5561
)
5662

5763
lazy val Stack = (project in file("."))
58-
.settings(JarJarRunner.globalSettings)
59-
.aggregate(RepackagedAsm, RepackagedMinlog, Instrumentation, FilterInjector, Util)
64+
.aggregate(Instrumentation, FilterInjector, SourceMapParser, Util)

filter-injector/src/main/java/com/codedx/bytefrog/filterinjector/FilterInjector.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.filterinjector;
220

321
import com.codedx.bytefrog.filterinjector.adapters.*;
422
import com.codedx.bytefrog.filterinjector.filter.InjectableFilter;
523

6-
import com.codedx.bytefrog.thirdparty.asm.ClassReader;
7-
import com.codedx.bytefrog.thirdparty.asm.ClassVisitor;
8-
import com.codedx.bytefrog.thirdparty.asm.Opcodes;
24+
import org.objectweb.asm.ClassReader;
25+
import org.objectweb.asm.ClassVisitor;
26+
import org.objectweb.asm.Opcodes;
927

10-
import com.codedx.bytefrog.thirdparty.minlog.Log;
28+
import com.esotericsoftware.minlog.Log;
1129

1230
/** A helper utility that, via instrumentation, can inject a filter into one of several known
1331
* servlet containers.

filter-injector/src/main/java/com/codedx/bytefrog/filterinjector/adapters/Adapter.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.filterinjector.adapters;
220

3-
import com.codedx.bytefrog.thirdparty.asm.ClassVisitor;
21+
import org.objectweb.asm.ClassVisitor;
422

523
/** Adapters are used for injecting servlet filters into a container at runtime, in a generic/
624
* extensible manner. Adapterss are enumerated in FilterInjector such that an instrumentation

filter-injector/src/main/java/com/codedx/bytefrog/filterinjector/adapters/JettyAdapter.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.filterinjector.adapters;
220

321
import com.codedx.bytefrog.filterinjector.filter.InjectableFilter;
422
import com.codedx.bytefrog.util.ClassLoaderUtil;
523

6-
import com.codedx.bytefrog.thirdparty.asm.*;
7-
import com.codedx.bytefrog.thirdparty.minlog.Log;
24+
import org.objectweb.asm.*;
25+
import com.esotericsoftware.minlog.Log;
826

927
/** For Jetty, injects the filter into instances of Jetty's ServletHandler.
1028
*

filter-injector/src/main/java/com/codedx/bytefrog/filterinjector/adapters/TomcatAdapter.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.filterinjector.adapters;
220

321
import java.lang.reflect.InvocationTargetException;
@@ -6,8 +24,8 @@
624
import com.codedx.bytefrog.filterinjector.filter.InjectableFilter;
725
import com.codedx.bytefrog.util.ClassLoaderUtil;
826

9-
import com.codedx.bytefrog.thirdparty.asm.*;
10-
import com.codedx.bytefrog.thirdparty.minlog.Log;
27+
import org.objectweb.asm.*;
28+
import com.esotericsoftware.minlog.Log;
1129

1230
/** For Tomcat, injects the filter into Tomcat contexts.
1331
*

filter-injector/src/main/java/com/codedx/bytefrog/filterinjector/filter/InjectableFilter.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.filterinjector.filter;
220

3-
import com.codedx.bytefrog.thirdparty.asm.MethodVisitor;
21+
import org.objectweb.asm.MethodVisitor;
422

523
/** InjectableFilter is an adapter for building bytecode to construct a filter for injection.
624
*

filter-injector/src/main/java/com/codedx/bytefrog/filterinjector/filter/ParameterlessFilter.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.filterinjector.filter;
220

321
import com.codedx.bytefrog.util.ClassLoaderUtil;
422

5-
import com.codedx.bytefrog.thirdparty.asm.MethodVisitor;
6-
import com.codedx.bytefrog.thirdparty.asm.Opcodes;
7-
import com.codedx.bytefrog.thirdparty.asm.Type;
23+
import org.objectweb.asm.MethodVisitor;
24+
import org.objectweb.asm.Opcodes;
25+
import org.objectweb.asm.Type;
826

927
/** An InjectableFilter adapter for filters with a parameterless constructor.
1028
*
@@ -24,9 +42,7 @@ public ParameterlessFilter(Type filterType, String name, String displayName) {
2442
}
2543

2644
public boolean isAvailable(final ClassLoader cl) {
27-
return
28-
ClassLoaderUtil.isAvailable(cl, filterType.getClassName()) ||
29-
ClassLoaderUtil.injectClass(cl, filterType);
45+
return ClassLoaderUtil.injectClass(cl, filterType);
3046
}
3147

3248
public void constructFilter(final MethodVisitor mv) {

instrumentation/src/main/java/com/codedx/bytefrog/instrumentation/BytecodeUtil.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.instrumentation;
220

3-
import com.codedx.bytefrog.thirdparty.asm.MethodVisitor;
4-
import com.codedx.bytefrog.thirdparty.asm.Opcodes;
21+
import org.objectweb.asm.MethodVisitor;
22+
import org.objectweb.asm.Opcodes;
523

624
/** Some basic bytecode helper utilities
725
*

instrumentation/src/main/java/com/codedx/bytefrog/instrumentation/ClassInspector.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
1+
/* bytefrog: a tracing instrumentation toolset for the JVM. For more information, see
2+
* <https://github.com/codedx/bytefrog>
3+
*
4+
* Copyright (C) 2014-2017 Code Dx, Inc. <https://codedx.com/>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package com.codedx.bytefrog.instrumentation;
220

321
import java.util.HashMap;
422
import java.util.LinkedList;
523
import java.util.Map;
624

7-
import com.codedx.bytefrog.thirdparty.asm.ClassVisitor;
8-
import com.codedx.bytefrog.thirdparty.asm.MethodVisitor;
9-
import com.codedx.bytefrog.thirdparty.asm.Opcodes;
25+
import org.objectweb.asm.ClassVisitor;
26+
import org.objectweb.asm.MethodVisitor;
27+
import org.objectweb.asm.Opcodes;
1028

11-
/** Simple class visitor that collects inspection data from MethodInspector.
29+
/** Simple class visitor that collects inspection data from MethodInspector. This includes
30+
* the ability to map line level information from the provided source map
1231
*
1332
* @author robertf
1433
*/
1534
public class ClassInspector extends ClassVisitor {
1635
private String fileName = null;
36+
private LineLevelMapper llm = null;
1737
private LinkedList<MethodInspector> inspectors = new LinkedList<>();
1838

1939
public ClassInspector() {
@@ -26,6 +46,7 @@ public ClassInspector() {
2646

2747
@Override public void visitSource(String source, String debug) {
2848
this.fileName = source;
49+
if (debug != null) llm = LineLevelMapper.parse(source, debug);
2950
super.visitSource(source, debug);
3051
}
3152

@@ -38,11 +59,14 @@ public ClassInspector() {
3859
/** Describes the results from pre-instrumentation inspection of a class. */
3960
public static class Result {
4061
private final String fileName;
62+
private final LineLevelMapper lineLevelMapper;
4163

4264
public String getFileName() { return fileName; }
65+
public LineLevelMapper getLineLevelMapper() { return lineLevelMapper; }
4366

44-
public Result(String fileName, LinkedList<MethodInspector> inspectors) {
67+
public Result(String fileName, LineLevelMapper lineLevelMapper, LinkedList<MethodInspector> inspectors) {
4568
this.fileName = fileName;
69+
this.lineLevelMapper = lineLevelMapper;
4670

4771
for (MethodInspector mi : inspectors) {
4872
final MethodInspector.Result inspection = mi.getResult(this);
@@ -63,6 +87,6 @@ public MethodInspector.Result lookupMethod(String name, String desc) {
6387
}
6488

6589
public Result getResult() {
66-
return new Result(fileName, inspectors);
90+
return new Result(fileName, llm, inspectors);
6791
}
6892
}

0 commit comments

Comments
 (0)