Skip to content
Commits on Source (11)
<!--
Copyright (C) 2009-2014 The Project Lombok Authors.
Copyright (C) 2009-2018 The Project Lombok Authors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -30,7 +30,7 @@
<target name="load-ipp" depends="download-ipp">
<taskdef classpath="lib/ivyplusplus.jar" resource="com/zwitserloot/ivyplusplus/antlib.xml" uri="antlib:com.zwitserloot.ivyplusplus" />
<ivy:ensureippversion version="1.13" property="ivyplusplus.minimumAvailable" />
<ivy:ensureippversion version="1.22" property="ivyplusplus.minimumAvailable" />
</target>
<target name="redownload-ipp" unless="ivyplusplus.minimumAvailable">
......@@ -89,7 +89,7 @@
<target name="version" depends="ensure-ipp" description="Shows the version number.">
<mkdir dir="build/pack" />
<javac srcdir="src/patcher" debug="on" destdir="build/pack" target="1.5" source="1.5" includes="lombok/patcher/Version.java" />
<ivy:compile srcdir="src/patcher" destdir="build/pack" target="1.5" source="1.5" ecj="true" includes="lombok/patcher/Version.java" />
<java
classname="lombok.patcher.Version"
classpath="build/pack"
......@@ -106,10 +106,11 @@
<unjar dest="build/packInjector">
<path refid="runtimeInjector.path" />
</unjar>
<delete file="build/pack/module-info.class" quiet="true" />
</target>
<target name="compile" depends="unpackLibs, ensureBuildDeps" description="Compiles lombok.patcher" unless="pointless">
<ivy:compile destdir="build/pack" target="1.5" source="1.5">
<ivy:compile destdir="build/pack" target="1.5" source="1.5" ecj="true">
<src path="src/patcher" />
<src path="src/injector" />
<classpath refid="build.path" />
......@@ -117,7 +118,8 @@
</target>
<target name="compileTests" depends="compile, ensureTestDeps" description="Compiles the unit tests" unless="skipTests">
<ivy:compile srcdir="test" destdir="build/tests" target="1.5" source="1.5">
<ivy:compile destdir="build/tests" target="1.5" source="1.5" ecj="true">
<src path="test" />
<classpath path="build/pack" />
<classpath refid="test.path" />
</ivy:compile>
......@@ -145,7 +147,6 @@
</fileset>
</batchtest>
</junit>
<echo level="info">All tests successful.</echo>
</target>
<target name="test" depends="-test" description="Runs the unit tests" />
......
<ivy-module version="2.0">
<info organisation="projectlombok.org" module="junit" revision="4.8.1" publication="20100225011200">
<license name="MIT License" url="http://www.opensource.org/licenses/mit-license.php" />
<ivyauthor name="KentBeck" url="http://www.threeriversinstitute.org/Kent%20Beck.htm" />
<description homepage="http://junit.org/" />
</info>
<configurations>
<conf name="test" />
</configurations>
<publications>
<artifact conf="test" url="https://cloud.github.com/downloads/KentBeck/junit/junit-4.8.1.jar" />
</publications>
</ivy-module>
......@@ -8,13 +8,12 @@
<conf name="contrib" />
</configurations>
<dependencies>
<dependency org="org.projectlombok" name="lombok" rev="1.12.6" conf="build->default" />
<dependency org="projectlombok.org" name="junit" rev="4.8.1" conf="test" />
<dependency org="junit" name="junit" rev="4.12" conf="test -> default"/>
<dependency org="com.jcraft" name="jsch" rev="0.1.42" conf="build->default" />
<dependency org="projectlombok.org" name="jsch-ant-fixed" rev="0.1.45" conf="build" />
<dependency org="org.ow2.asm" name="asm" rev="5.0.1" conf="runtime, build -> default; contrib->sources" />
<dependency org="org.ow2.asm" name="asm-tree" rev="5.0.1" conf="runtime, build->default; contrib->sources" />
<dependency org="org.ow2.asm" name="asm-commons" rev="5.0.1" conf="runtime, build->default; contrib->sources" />
<dependency org="org.ow2.asm" name="asm" rev="6.2.1" conf="runtime, build -> default; contrib->sources" />
<dependency org="org.ow2.asm" name="asm-tree" rev="6.2.1" conf="runtime, build->default; contrib->sources" />
<dependency org="org.ow2.asm" name="asm-commons" rev="6.2.1" conf="runtime, build->default; contrib->sources" />
<dependency org="net.java.dev.jna" name="jna" rev="3.2.2" conf="runtimeInjector, build->master" />
</dependencies>
</ivy-module>
lombok-patcher (0.28-1) unstable; urgency=medium
* New upstream version 0.28.
- Fix FTBFS with OpenJDK 10. (Closes: 906383)
* Switch to compat level 11.
* Use https for Format field.
* Declare compliance with Debian Policy 4.2.1.
* Update build.patch for new release.
-- Markus Koschany <apo@debian.org> Tue, 02 Oct 2018 22:46:06 +0200
lombok-patcher (0.22-2) unstable; urgency=medium
* Team upload.
......
......@@ -7,7 +7,7 @@ Uploaders:
Build-Depends:
ant,
ant-optional,
debhelper (>= 10),
debhelper (>= 11),
default-jdk,
ivyplusplus,
javahelper,
......@@ -15,7 +15,7 @@ Build-Depends:
libjna-java,
libjsch-java,
liblombok-java
Standards-Version: 4.1.1
Standards-Version: 4.2.1
Homepage: https://projectlombok.org
Vcs-Git: https://anonscm.debian.org/git/pkg-java/lombok-patcher.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/lombok-patcher.git
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: lombok.patcher
Source: https://github.com/rzwitserloot/lombok.patcher
......@@ -7,7 +7,7 @@ Copyright: 2009-2015 The Project Lombok Authors.
License: Expat
Files: debian/*
Copyright: 2016, Markus Koschany <apo@debian.org>
Copyright: 2016-2018, Markus Koschany <apo@debian.org>
License: Expat
......
dist/lombok.patcher.jar
dist/lombok.injector-0.22.jar
dist/lombok.injector-0.28.jar
From: Markus Koschany <apo@debian.org>
Date: Sun, 14 Feb 2016 17:45:27 +0100
Date: Tue, 2 Oct 2018 22:43:11 +0200
Subject: build
Do not download anything from the web and ensure that Debian's system jars are
used.
Forwarded: not-needed
---
build.xml | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/build.xml b/build.xml
index 61f7a85..9db941a 100644
index e93ec7e..74d0460 100644
--- a/build.xml
+++ b/build.xml
@@ -87,7 +87,7 @@
......@@ -21,7 +18,7 @@ index 61f7a85..9db941a 100644
- <target name="version" depends="ensure-ipp" description="Shows the version number.">
+ <target name="version" depends="" description="Shows the version number.">
<mkdir dir="build/pack" />
<javac srcdir="src/patcher" debug="on" destdir="build/pack" target="1.5" source="1.5" includes="lombok/patcher/Version.java" />
<ivy:compile srcdir="src/patcher" destdir="build/pack" target="1.5" source="1.5" ecj="true" includes="lombok/patcher/Version.java" />
<java
@@ -99,7 +99,7 @@
<echo level="info">Lombok patcher version: ${lombok.patcher.version}</echo>
......@@ -32,13 +29,13 @@ index 61f7a85..9db941a 100644
<unjar dest="build/pack">
<path refid="runtime.path" />
</unjar>
@@ -108,11 +108,12 @@
</unjar>
@@ -109,11 +109,12 @@
<delete file="build/pack/module-info.class" quiet="true" />
</target>
- <target name="compile" depends="unpackLibs, ensureBuildDeps" description="Compiles lombok.patcher" unless="pointless">
+ <target name="compile" depends="" description="Compiles lombok.patcher" unless="pointless">
<ivy:compile destdir="build/pack" target="1.5" source="1.5">
<ivy:compile destdir="build/pack" target="1.5" source="1.5" ecj="true">
<src path="src/patcher" />
<src path="src/injector" />
<classpath refid="build.path" />
......@@ -46,7 +43,7 @@ index 61f7a85..9db941a 100644
</ivy:compile>
</target>
@@ -133,7 +134,7 @@
@@ -135,7 +136,7 @@
</condition>
</target>
......@@ -55,7 +52,7 @@ index 61f7a85..9db941a 100644
<junit haltonfailure="yes" fork="on">
<formatter type="plain" usefile="false" unless="tests.quiet" />
<classpath path="build/pack" />
@@ -150,7 +151,7 @@
@@ -151,7 +152,7 @@
<target name="test" depends="-test" description="Runs the unit tests" />
......@@ -64,7 +61,7 @@ index 61f7a85..9db941a 100644
<mkdir dir="dist" />
<jar basedir="build/pack" destfile="dist/lombok.patcher-${lombok.patcher.version}.jar" />
<jar destfile="dist/lombok.injector-${lombok.patcher.version}.jar">
@@ -160,7 +161,7 @@
@@ -161,7 +162,7 @@
<copy file="dist/lombok.patcher-${lombok.patcher.version}.jar" tofile="dist/lombok.patcher.jar" />
</target>
......@@ -73,7 +70,7 @@ index 61f7a85..9db941a 100644
<ivy:configure file="buildScripts/ivysettings.xml" />
</target>
@@ -199,7 +200,7 @@
@@ -200,7 +201,7 @@
<echo>automated uploading and deployment temporarily disabled. Upload dist/lombok.patcher-${lombok.patcher.version}.jar to the server and deploy manually.</echo>
</target>
......
/*
* Copyright (C) 2009-2010 The Project Lombok Authors.
* Copyright (C) 2009-2017 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -27,11 +27,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;
/**
* Represents a method you write yourself; calls to it will be inserted into
* code-to-be-patched by a {@code PatchScript}.
......@@ -42,25 +37,12 @@ import lombok.ToString;
*
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#1169">JVM Spec on method names and descriptors</a>
*/
@ToString
@EqualsAndHashCode
public class Hook {
@Getter @NonNull
private final String className;
@Getter @NonNull
private final String methodName;
@Getter @NonNull
private final String returnType;
@Getter @NonNull
private final List<String> parameterTypes;
public boolean isConstructor() {
return "<init>".equals(methodName);
}
public Hook(String className, String methodName, String returnType, String... parameterTypes) {
if (className == null) throw new NullPointerException("classSpec");
if (methodName == null) throw new NullPointerException("methodName");
......@@ -75,6 +57,26 @@ public class Hook {
this.parameterTypes = Collections.unmodifiableList(params);
}
public boolean isConstructor() {
return "<init>".equals(methodName);
}
public String getClassName() {
return className;
}
public String getMethodName() {
return methodName;
}
public String getReturnType() {
return returnType;
}
public List<String> getParameterTypes() {
return parameterTypes;
}
public String getClassSpec() {
return convertType(className);
}
......@@ -130,4 +132,38 @@ public class Hook {
}
return out.toString();
}
@Override public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((methodName == null) ? 0 : methodName.hashCode());
result = prime * result + ((parameterTypes == null) ? 0 : parameterTypes.hashCode());
result = prime * result + ((returnType == null) ? 0 : returnType.hashCode());
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Hook other = (Hook) obj;
if (className == null) {
if (other.className != null) return false;
} else if (!className.equals(other.className)) return false;
if (methodName == null) {
if (other.methodName != null) return false;
} else if (!methodName.equals(other.methodName)) return false;
if (parameterTypes == null) {
if (other.parameterTypes != null) return false;
} else if (!parameterTypes.equals(other.parameterTypes)) return false;
if (returnType == null) {
if (other.returnType != null) return false;
} else if (!returnType.equals(other.returnType)) return false;
return true;
}
@Override public String toString() {
return "Hook [className=" + className + ", methodName=" + methodName + ", returnType=" + returnType + ", parameterTypes=" + parameterTypes + "]";
}
}
/*
* Copyright (C) 2009 The Project Lombok Authors.
* Copyright (C) 2009-2017 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -26,8 +26,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import lombok.Getter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
......@@ -40,8 +38,6 @@ import org.objectweb.asm.Opcodes;
*/
public class MethodLogistics {
private final int staticOffset;
@Getter
private final int returnOpcode;
private final int returnSize;
......@@ -94,6 +90,10 @@ public class MethodLogistics {
return this.paramSizes.size();
}
public int getReturnOpcode() {
return returnOpcode;
}
/**
* Writes the opcode to load the i-th parameter to the supplied {@code MethodVisitor}.
*
......
/*
* Copyright (C) 2009 The Project Lombok Authors.
* Copyright (C) 2009-2017 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -30,10 +30,6 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
/**
* Represents a target method that you want to transform.
*
......@@ -41,24 +37,33 @@ import lombok.ToString;
* overloaded the method name. You can choose to focus on just one of a set of overloaded methods by also specifying return
* type and parameter types.
*/
@ToString
@EqualsAndHashCode
public final class MethodTarget implements TargetMatcher {
@Getter
private final String classSpec;
@Getter
private final String methodName;
@Getter
private final String returnSpec;
@Getter
private final List<String> parameterSpec;
@Getter
private boolean hasDescription;
public String getClassSpec() {
return classSpec;
}
public String getMethodName() {
return methodName;
}
public String getReturnSpec() {
return returnSpec;
}
public List<String> getParameterSpec() {
return parameterSpec;
}
public boolean isHasDescription() {
return hasDescription;
}
/**
* Target any method with the provided name that appears in the provided class, regardless of return type and parameter types.
*
......@@ -216,4 +221,40 @@ public final class MethodTarget implements TargetMatcher {
public static boolean typeMatches(String type, String pattern) {
return type.replace("/", ".").equals(pattern);
}
@Override public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((classSpec == null) ? 0 : classSpec.hashCode());
result = prime * result + (hasDescription ? 1231 : 1237);
result = prime * result + ((methodName == null) ? 0 : methodName.hashCode());
result = prime * result + ((parameterSpec == null) ? 0 : parameterSpec.hashCode());
result = prime * result + ((returnSpec == null) ? 0 : returnSpec.hashCode());
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
MethodTarget other = (MethodTarget) obj;
if (classSpec == null) {
if (other.classSpec != null) return false;
} else if (!classSpec.equals(other.classSpec)) return false;
if (hasDescription != other.hasDescription) return false;
if (methodName == null) {
if (other.methodName != null) return false;
} else if (!methodName.equals(other.methodName)) return false;
if (parameterSpec == null) {
if (other.parameterSpec != null) return false;
} else if (!parameterSpec.equals(other.parameterSpec)) return false;
if (returnSpec == null) {
if (other.returnSpec != null) return false;
} else if (!returnSpec.equals(other.returnSpec)) return false;
return true;
}
@Override public String toString() {
return "MethodTarget[classSpec=" + classSpec + ", methodName=" + methodName + ", returnSpec=" + returnSpec + ", parameterSpec=" + parameterSpec + ", hasDescription=" + hasDescription + "]";
}
}
/*
* Copyright (C) 2009-2012 The Project Lombok Authors.
* Copyright (C) 2009-2017 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -22,15 +22,13 @@
package lombok.patcher;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import lombok.Cleanup;
import lombok.Getter;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
......@@ -141,8 +139,9 @@ public abstract class PatchScript {
}
private static byte[] readStream(String resourceName) {
InputStream wrapStream = null;
try {
@Cleanup InputStream wrapStream = PatchScript.class.getResourceAsStream(resourceName);
wrapStream = PatchScript.class.getResourceAsStream(resourceName);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] b = new byte[65536];
while (true) {
......@@ -154,12 +153,16 @@ public abstract class PatchScript {
return baos.toByteArray();
} catch (Exception e) {
throw new IllegalArgumentException("resource " + resourceName + " does not exist.", e);
} finally {
if (wrapStream != null) try {
wrapStream.close();
} catch (IOException ignore) {}
}
}
private static abstract class NoopClassVisitor extends ClassVisitor {
public NoopClassVisitor() {
super(Opcodes.ASM4);
super(Opcodes.ASM6);
}
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {}
......@@ -205,7 +208,7 @@ public abstract class PatchScript {
private static final class InsertBodyOfMethodIntoAnotherVisitor extends MethodVisitor {
private InsertBodyOfMethodIntoAnotherVisitor(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
super(Opcodes.ASM6, mv);
}
@Override public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { return null; }
......@@ -235,18 +238,22 @@ public abstract class PatchScript {
*/
protected static class MethodPatcher extends ClassVisitor {
private List<TargetMatcher> targets = new ArrayList<TargetMatcher>();
private @Getter String ownClassSpec;
private String ownClassSpec;
private final MethodPatcherFactory factory;
private List<Hook> transplants = new ArrayList<Hook>();
private final TransplantMapper transplantMapper;
private int classFileFormatVersion;
public MethodPatcher(ClassVisitor cv, TransplantMapper transplantMapper, MethodPatcherFactory factory) {
super(Opcodes.ASM4, cv);
super(Opcodes.ASM6, cv);
this.factory = factory;
this.transplantMapper = transplantMapper;
}
public String getOwnClassSpec() {
return ownClassSpec;
}
/**
* The {@code factory} will be called for any methods that match any added target.
*/
......
/*
* Copyright (C) 2009 The Project Lombok Authors.
* Copyright (C) 2009-2017 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -25,8 +25,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
/**
* Various patch scripts support various method parmater signatures in your hook methods; use StackRequest values to specify
* which parameters you want. It doesn't matter how you specify your StackRequest values; you <em>MUST</em> order your parameters
......@@ -35,13 +33,16 @@ import lombok.Getter;
public enum StackRequest {
RETURN_VALUE(-1), THIS(-1), PARAM1(0), PARAM2(1), PARAM3(2), PARAM4(3), PARAM5(4), PARAM6(5);
@Getter
private final int paramPos;
StackRequest(int paramPos) {
this.paramPos = paramPos;
}
public int getParamPos() {
return paramPos;
}
public static final List<StackRequest> PARAMS_IN_ORDER = Collections.unmodifiableList(Arrays.asList(
PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6));
}
/*
* Copyright (C) 2009-2016 The Project Lombok Authors.
* Copyright (C) 2009-2018 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -26,7 +26,7 @@ package lombok.patcher;
*/
public class Version {
// ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries).
private static final String VERSION = "0.22";
private static final String VERSION = "0.28";
private Version() {
//Prevent instantiation
......
......@@ -65,7 +65,7 @@ public class AddFieldScript extends PatchScript {
}
@Override protected ClassVisitor createClassVisitor(ClassWriter writer, String classSpec, TransplantMapper transplantMapper) {
return new ClassVisitor(Opcodes.ASM4, writer) {
return new ClassVisitor(Opcodes.ASM6, writer) {
private boolean alreadyAdded = false;
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
......
......@@ -82,7 +82,7 @@ public class ExitFromMethodEarlyScript extends MethodLevelPatchScript {
private final String ownClassSpec;
public ExitEarly(MethodVisitor mv, MethodLogistics logistics, String ownClassSpec) {
super(Opcodes.ASM4, mv);
super(Opcodes.ASM6, mv);
this.logistics = logistics;
this.ownClassSpec = ownClassSpec;
}
......
......@@ -74,7 +74,7 @@ public class ReplaceMethodCallScript extends MethodLevelPatchScript {
private final MethodLogistics logistics;
public ReplaceMethodCall(MethodVisitor mv, String ownClassSpec, MethodLogistics logistics) {
super(Opcodes.ASM4, mv);
super(Opcodes.ASM6, mv);
this.ownClassSpec = ownClassSpec;
this.logistics = logistics;
}
......
......@@ -107,7 +107,7 @@ public class SetSymbolDuringMethodCallScript extends MethodLevelPatchScript {
private final List<WrapperMethodDescriptor> descriptors;
public WrapWithSymbol(String selfMethodName, MethodVisitor mv, String selfTypeName, List<WrapperMethodDescriptor> descriptors) {
super(Opcodes.ASM4, mv);
super(Opcodes.ASM6, mv);
this.selfMethodName = selfMethodName;
this.selfTypeName = selfTypeName;
this.descriptors = descriptors;
......
......@@ -80,7 +80,7 @@ public class WrapMethodCallScript extends MethodLevelPatchScript {
private final MethodLogistics logistics;
public WrapMethodCall(MethodVisitor mv, String ownClassSpec, MethodLogistics logistics) {
super(Opcodes.ASM4, mv);
super(Opcodes.ASM6, mv);
this.ownClassSpec = ownClassSpec;
this.logistics = logistics;
}
......