Skip to content

Commit e1dbfb1

Browse files
committed
Include ASM in agent rather than using saker.build.thirdparty
So we can update manually for newer JDKs. Also include tests for other JDKs in CI.
1 parent 896c18c commit e1dbfb1

Some content is hidden

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

45 files changed

+19042
-40
lines changed

azure-pipelines.yml

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,48 @@ trigger:
44
pool:
55
vmImage: 'ubuntu-latest'
66

7-
steps:
8-
- script: curl https://api.nest.saker.build/bundle/download/saker.build-v$(curl -s https://mirror.nest.saker.build/badges/saker.build/latest.txt) -o saker.build.jar
9-
displayName: 'Download saker.build'
10-
- script: |
11-
set -e
12-
curl -s https://gist.githubusercontent.com/Sipkab/f71ecb5e2167a2b0fced6736d703b8a5/raw/35ab3a1d94a32a1183a05cdb2498943937326993/azure_ubuntu_jdksetup.sh -o /tmp/azure_ubuntu_jdksetup.sh
13-
echo "##vso[task.setvariable variable=JAVA_HOME_8_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 8)" &
14-
echo "##vso[task.setvariable variable=JAVA_HOME_9_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 9)" &
15-
wait < <(jobs -p)
16-
displayName: 'Setup JDKs'
17-
- script: java -jar saker.build.jar -bd build "-EUsaker.java.jre.install.locations=$(JAVA_HOME_8_X64);$(JAVA_HOME_9_X64)" test
18-
displayName: 'Test'
19-
- script: java -jar saker.build.jar -bd build "-EUsaker.java.jre.install.locations=$(JAVA_HOME_8_X64);$(JAVA_HOME_9_X64)" exportall
20-
displayName: 'Export'
7+
jobs:
8+
- job: jdk8
9+
steps:
10+
- script: curl https://api.nest.saker.build/bundle/download/saker.build-v$(curl -s https://mirror.nest.saker.build/badges/saker.build/latest.txt) -o saker.build.jar
11+
displayName: 'Download saker.build'
12+
- script: |
13+
set -e
14+
curl -s https://gist.githubusercontent.com/Sipkab/f71ecb5e2167a2b0fced6736d703b8a5/raw/azure_ubuntu_jdksetup.sh -o /tmp/azure_ubuntu_jdksetup.sh
15+
echo "##vso[task.setvariable variable=JAVA_HOME_8_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 8)" &
16+
echo "##vso[task.setvariable variable=JAVA_HOME_9_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 9)" &
17+
wait < <(jobs -p)
18+
displayName: 'Setup JDKs'
19+
- script: java -jar saker.build.jar -bd build "-EUsaker.java.jre.install.locations=$(JAVA_HOME_8_X64);$(JAVA_HOME_9_X64)" test
20+
displayName: 'Test JDK 8'
21+
- script: java -jar saker.build.jar -bd build "-EUsaker.java.jre.install.locations=$(JAVA_HOME_8_X64);$(JAVA_HOME_9_X64)" exportall
22+
displayName: 'Export'
23+
24+
- job: jdk9
25+
steps:
26+
- script: curl https://api.nest.saker.build/bundle/download/saker.build-v$(curl -s https://mirror.nest.saker.build/badges/saker.build/latest.txt) -o saker.build.jar
27+
displayName: 'Download saker.build'
28+
- script: |
29+
set -e
30+
curl -s https://gist.githubusercontent.com/Sipkab/f71ecb5e2167a2b0fced6736d703b8a5/raw/azure_ubuntu_jdksetup.sh -o /tmp/azure_ubuntu_jdksetup.sh
31+
echo "##vso[task.setvariable variable=JAVA_HOME_8_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 8)" &
32+
echo "##vso[task.setvariable variable=JAVA_HOME_9_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 9)" &
33+
wait < <(jobs -p)
34+
displayName: 'Setup JDKs'
35+
- script: java -jar saker.build.jar -bd build "-EUsaker.java.jre.install.locations=$(JAVA_HOME_8_X64);$(JAVA_HOME_9_X64)" testjava9
36+
displayName: 'Test JDK 9'
37+
38+
- job: jdk14
39+
steps:
40+
- script: curl https://api.nest.saker.build/bundle/download/saker.build-v$(curl -s https://mirror.nest.saker.build/badges/saker.build/latest.txt) -o saker.build.jar
41+
displayName: 'Download saker.build'
42+
- script: |
43+
set -e
44+
curl -s https://gist.githubusercontent.com/Sipkab/f71ecb5e2167a2b0fced6736d703b8a5/raw/azure_ubuntu_jdksetup.sh -o /tmp/azure_ubuntu_jdksetup.sh
45+
echo "##vso[task.setvariable variable=JAVA_HOME_8_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 8)" &
46+
echo "##vso[task.setvariable variable=JAVA_HOME_9_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 9)" &
47+
echo "##vso[task.setvariable variable=JAVA_HOME_14_X64]$(bash /tmp/azure_ubuntu_jdksetup.sh 14)" &
48+
wait < <(jobs -p)
49+
displayName: 'Setup JDKs'
50+
- script: java -jar saker.build.jar -bd build "-EUsaker.java.jre.install.locations=$(JAVA_HOME_8_X64);$(JAVA_HOME_9_X64);$(JAVA_HOME_14_X64)" testjava14
51+
displayName: 'Test JDK 14'

saker.build

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
global(VERSION_saker.java.testing) = "0.8.0"
1+
global(VERSION_saker.java.testing) = "0.8.1"
22

33
global(TOOLS_OPTIONS) = [
44
{
@@ -436,6 +436,12 @@ testjava9(){
436436
jreversion: 9,
437437
)
438438
}
439+
testjava14(){
440+
include(
441+
test,
442+
jreversion: 14,
443+
)
444+
}
439445

440446
_testapicompile(
441447
in enabled = false,

src-agent-common/saker/java/testing/agent/ClassLoaderResourceDelegateClassVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616
package saker.java.testing.agent;
1717

18-
import saker.build.thirdparty.org.objectweb.asm.ClassVisitor;
19-
import saker.build.thirdparty.org.objectweb.asm.MethodVisitor;
20-
import saker.build.thirdparty.org.objectweb.asm.Opcodes;
21-
import saker.build.thirdparty.org.objectweb.asm.Type;
18+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassVisitor;
19+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.MethodVisitor;
20+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Opcodes;
21+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Type;
2222
import saker.java.testing.bootstrapagent.TestFileRequestor;
2323

2424
class ClassLoaderResourceDelegateClassVisitor extends ClassVisitor {

src-agent-common/saker/java/testing/agent/ClassMethodDelegateClassVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package saker.java.testing.agent;
1717

18-
import saker.build.thirdparty.org.objectweb.asm.ClassVisitor;
19-
import saker.build.thirdparty.org.objectweb.asm.MethodVisitor;
20-
import saker.build.thirdparty.org.objectweb.asm.Opcodes;
18+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassVisitor;
19+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.MethodVisitor;
20+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Opcodes;
2121

2222
class ClassMethodDelegateClassVisitor extends ClassVisitor {
2323
private String forwardParameterDescriptor;

src-agent-common/saker/java/testing/agent/ConstructorDelegateClassVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package saker.java.testing.agent;
1717

18-
import saker.build.thirdparty.org.objectweb.asm.ClassVisitor;
19-
import saker.build.thirdparty.org.objectweb.asm.MethodVisitor;
20-
import saker.build.thirdparty.org.objectweb.asm.Opcodes;
18+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassVisitor;
19+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.MethodVisitor;
20+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Opcodes;
2121

2222
class ConstructorDelegateClassVisitor extends ClassVisitor {
2323

src-agent-common/saker/java/testing/agent/ExitCallDisablerClassVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616
package saker.java.testing.agent;
1717

18-
import saker.build.thirdparty.org.objectweb.asm.ClassVisitor;
19-
import saker.build.thirdparty.org.objectweb.asm.MethodVisitor;
20-
import saker.build.thirdparty.org.objectweb.asm.Opcodes;
21-
import saker.build.thirdparty.org.objectweb.asm.Type;
18+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassVisitor;
19+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.MethodVisitor;
20+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Opcodes;
21+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Type;
2222
import saker.java.testing.bootstrapagent.InstrumentationData;
2323

2424
class ExitCallDisablerClassVisitor extends ClassVisitor {

src-agent-common/saker/java/testing/agent/MethodInvocationLoggerClassVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import java.lang.reflect.Field;
2020
import java.lang.reflect.Method;
2121

22-
import saker.build.thirdparty.org.objectweb.asm.ClassVisitor;
23-
import saker.build.thirdparty.org.objectweb.asm.MethodVisitor;
24-
import saker.build.thirdparty.org.objectweb.asm.Opcodes;
25-
import saker.build.thirdparty.org.objectweb.asm.Type;
22+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassVisitor;
23+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.MethodVisitor;
24+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Opcodes;
25+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Type;
2626
import saker.java.testing.bootstrapagent.InstrumentationData;
2727

2828
class MethodInvocationLoggerClassVisitor extends ClassVisitor {

src-agent-common/saker/java/testing/agent/UserClassFileTransformer.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import java.util.HashSet;
2222
import java.util.Set;
2323

24-
import saker.build.thirdparty.org.objectweb.asm.ClassReader;
25-
import saker.build.thirdparty.org.objectweb.asm.ClassVisitor;
26-
import saker.build.thirdparty.org.objectweb.asm.ClassWriter;
27-
import saker.build.thirdparty.org.objectweb.asm.Opcodes;
28-
import saker.build.thirdparty.org.objectweb.asm.Type;
24+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassReader;
25+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassVisitor;
26+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.ClassWriter;
27+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Opcodes;
28+
import saker.java.testing.agent.thirdparty.org.objectweb.asm.Type;
2929
import saker.java.testing.bootstrapagent.NioFileSystemProviderSakerProxy;
3030

3131
class UserClassFileTransformer implements ClassFileTransformer {
@@ -97,10 +97,13 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
9797
cr.accept(lastcv, 0);
9898
return cw.toByteArray();
9999
} catch (Throwable e) {
100-
System.err.println("TestingInstrumentationAgent.UserClassFileTransformer.transform() failed to transform "
101-
+ className + " in " + loader + " bytelen: " + classfileBuffer.length);
100+
System.err.println("Failed to transform class bytes for " + className);
101+
System.err.println("Exiting...");
102102
// System.err.println("Bytes: " + Arrays.toString(classfileBuffer));
103103
e.printStackTrace();
104+
//exit as the class transformation failure is considered to be fatal. this also notifies the
105+
//testing task that the testing cannot be started.
106+
System.exit(-1);
104107
}
105108
return null;
106109
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
// ASM: a very small and fast Java bytecode manipulation framework
2+
// Copyright (c) 2000-2011 INRIA, France Telecom
3+
// All rights reserved.
4+
//
5+
// Redistribution and use in source and binary forms, with or without
6+
// modification, are permitted provided that the following conditions
7+
// are met:
8+
// 1. Redistributions of source code must retain the above copyright
9+
// notice, this list of conditions and the following disclaimer.
10+
// 2. Redistributions in binary form must reproduce the above copyright
11+
// notice, this list of conditions and the following disclaimer in the
12+
// documentation and/or other materials provided with the distribution.
13+
// 3. Neither the name of the copyright holders nor the names of its
14+
// contributors may be used to endorse or promote products derived from
15+
// this software without specific prior written permission.
16+
//
17+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27+
// THE POSSIBILITY OF SUCH DAMAGE.
28+
package saker.java.testing.agent.thirdparty.org.objectweb.asm;
29+
30+
/**
31+
* A visitor to visit a Java annotation. The methods of this class must be called in the following
32+
* order: ( {@code visit} | {@code visitEnum} | {@code visitAnnotation} | {@code visitArray} )*
33+
* {@code visitEnd}.
34+
*
35+
* @author Eric Bruneton
36+
* @author Eugene Kuleshov
37+
*/
38+
public abstract class AnnotationVisitor {
39+
40+
/**
41+
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
42+
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
43+
*/
44+
protected final int api;
45+
46+
/**
47+
* The annotation visitor to which this visitor must delegate method calls. May be {@literal
48+
* null}.
49+
*/
50+
protected AnnotationVisitor av;
51+
52+
/**
53+
* Constructs a new {@link AnnotationVisitor}.
54+
*
55+
* @param api the ASM API version implemented by this visitor. Must be one of {@link
56+
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
57+
*/
58+
public AnnotationVisitor(final int api) {
59+
this(api, null);
60+
}
61+
62+
/**
63+
* Constructs a new {@link AnnotationVisitor}.
64+
*
65+
* @param api the ASM API version implemented by this visitor. Must be one of {@link
66+
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
67+
* @param annotationVisitor the annotation visitor to which this visitor must delegate method
68+
* calls. May be {@literal null}.
69+
*/
70+
public AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) {
71+
if (api != Opcodes.ASM7
72+
&& api != Opcodes.ASM6
73+
&& api != Opcodes.ASM5
74+
&& api != Opcodes.ASM4
75+
&& api != Opcodes.ASM8_EXPERIMENTAL) {
76+
throw new IllegalArgumentException("Unsupported api " + api);
77+
}
78+
if (api == Opcodes.ASM8_EXPERIMENTAL) {
79+
Constants.checkAsm8Experimental(this);
80+
}
81+
this.api = api;
82+
this.av = annotationVisitor;
83+
}
84+
85+
/**
86+
* Visits a primitive value of the annotation.
87+
*
88+
* @param name the value name.
89+
* @param value the actual value, whose type must be {@link Byte}, {@link Boolean}, {@link
90+
* Character}, {@link Short}, {@link Integer} , {@link Long}, {@link Float}, {@link Double},
91+
* {@link String} or {@link Type} of {@link Type#OBJECT} or {@link Type#ARRAY} sort. This
92+
* value can also be an array of byte, boolean, short, char, int, long, float or double values
93+
* (this is equivalent to using {@link #visitArray} and visiting each array element in turn,
94+
* but is more convenient).
95+
*/
96+
public void visit(final String name, final Object value) {
97+
if (av != null) {
98+
av.visit(name, value);
99+
}
100+
}
101+
102+
/**
103+
* Visits an enumeration value of the annotation.
104+
*
105+
* @param name the value name.
106+
* @param descriptor the class descriptor of the enumeration class.
107+
* @param value the actual enumeration value.
108+
*/
109+
public void visitEnum(final String name, final String descriptor, final String value) {
110+
if (av != null) {
111+
av.visitEnum(name, descriptor, value);
112+
}
113+
}
114+
115+
/**
116+
* Visits a nested annotation value of the annotation.
117+
*
118+
* @param name the value name.
119+
* @param descriptor the class descriptor of the nested annotation class.
120+
* @return a visitor to visit the actual nested annotation value, or {@literal null} if this
121+
* visitor is not interested in visiting this nested annotation. <i>The nested annotation
122+
* value must be fully visited before calling other methods on this annotation visitor</i>.
123+
*/
124+
public AnnotationVisitor visitAnnotation(final String name, final String descriptor) {
125+
if (av != null) {
126+
return av.visitAnnotation(name, descriptor);
127+
}
128+
return null;
129+
}
130+
131+
/**
132+
* Visits an array value of the annotation. Note that arrays of primitive types (such as byte,
133+
* boolean, short, char, int, long, float or double) can be passed as value to {@link #visit
134+
* visit}. This is what {@link ClassReader} does.
135+
*
136+
* @param name the value name.
137+
* @return a visitor to visit the actual array value elements, or {@literal null} if this visitor
138+
* is not interested in visiting these values. The 'name' parameters passed to the methods of
139+
* this visitor are ignored. <i>All the array values must be visited before calling other
140+
* methods on this annotation visitor</i>.
141+
*/
142+
public AnnotationVisitor visitArray(final String name) {
143+
if (av != null) {
144+
return av.visitArray(name);
145+
}
146+
return null;
147+
}
148+
149+
/** Visits the end of the annotation. */
150+
public void visitEnd() {
151+
if (av != null) {
152+
av.visitEnd();
153+
}
154+
}
155+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy