Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,35 @@
<dependencies>

<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
<groupId>org.eclipse.parsson</groupId>
<artifactId>jakarta.json</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2.1</version>
<version>9.7</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>6.2.1</version>
<version>9.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down Expand Up @@ -110,13 +121,26 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<argLine>
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;

import javax.ws.rs.ApplicationPath;
import jakarta.ws.rs.ApplicationPath;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -114,7 +114,7 @@ public Resources analyze(Set<Path> projectClassPaths, Set<Path> projectSourcePat

private boolean isJAXRSRootResource(String className) {
final Class<?> clazz = JavaUtils.loadClassFromName(className);
return clazz != null && (isAnnotationPresent(clazz, javax.ws.rs.Path.class) || isAnnotationPresent(clazz, ApplicationPath.class));
return clazz != null && (isAnnotationPresent(clazz, jakarta.ws.rs.Path.class) || isAnnotationPresent(clazz, ApplicationPath.class));
}

private void analyzeClass(final String className, ClassResult classResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import com.sebastian_daschner.jaxrs_analyzer.model.methods.Method;
import com.sebastian_daschner.jaxrs_analyzer.model.methods.MethodIdentifier;

import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand All @@ -49,13 +49,13 @@ enum KnownResponseResultMethod implements IdentifiableMethod {

RESPONSE_BUILDER_BUILD(ofNonStatic(CLASS_RESPONSE_BUILDER, "build", RESPONSE), (object, arguments) -> object),

RESPONSE_BUILDER_CACHE_CONTROL(ofNonStatic(CLASS_RESPONSE_BUILDER, "cacheControl", RESPONSE_BUILDER, "Ljavax/ws/rs/core/CacheControl;"), (object, arguments) ->
RESPONSE_BUILDER_CACHE_CONTROL(ofNonStatic(CLASS_RESPONSE_BUILDER, "cacheControl", RESPONSE_BUILDER, "Ljakarta/ws/rs/core/CacheControl;"), (object, arguments) ->
addHeader(object, HttpHeaders.CACHE_CONTROL)),

RESPONSE_BUILDER_CONTENT_LOCATION(ofNonStatic(CLASS_RESPONSE_BUILDER, "contentLocation", RESPONSE_BUILDER, URI), (object, arguments) ->
addHeader(object, HttpHeaders.CONTENT_LOCATION)),

RESPONSE_BUILDER_COOKIE(ofNonStatic(CLASS_RESPONSE_BUILDER, "cookie", RESPONSE_BUILDER, "[Ljavax/ws/rs/core/NewCookie;"), (object, arguments) ->
RESPONSE_BUILDER_COOKIE(ofNonStatic(CLASS_RESPONSE_BUILDER, "cookie", RESPONSE_BUILDER, "[Ljakarta/ws/rs/core/NewCookie;"), (object, arguments) ->
addHeader(object, HttpHeaders.SET_COOKIE)),

RESPONSE_BUILDER_ENCODING(ofNonStatic(CLASS_RESPONSE_BUILDER, "encoding", RESPONSE_BUILDER, STRING), (object, arguments) ->
Expand Down Expand Up @@ -91,7 +91,7 @@ enum KnownResponseResultMethod implements IdentifiableMethod {
RESPONSE_BUILDER_LINK_STRING(ofNonStatic(CLASS_RESPONSE_BUILDER, "link", RESPONSE_BUILDER, STRING, STRING), (object, arguments) ->
addHeader(object, HttpHeaders.LINK)),

RESPONSE_BUILDER_LINKS(ofNonStatic(CLASS_RESPONSE_BUILDER, "links", RESPONSE_BUILDER, "[Ljavax/ws/rs/core/Link;"), (object, arguments) ->
RESPONSE_BUILDER_LINKS(ofNonStatic(CLASS_RESPONSE_BUILDER, "links", RESPONSE_BUILDER, "[Ljakarta/ws/rs/core/Link;"), (object, arguments) ->
addHeader(object, HttpHeaders.LINK)),

RESPONSE_BUILDER_LOCATION(ofNonStatic(CLASS_RESPONSE_BUILDER, "location", RESPONSE_BUILDER, URI), (object, arguments) ->
Expand All @@ -115,7 +115,7 @@ enum KnownResponseResultMethod implements IdentifiableMethod {
RESPONSE_BUILDER_TAG_STRING(ofNonStatic(CLASS_RESPONSE_BUILDER, "tag", RESPONSE_BUILDER, STRING), (object, arguments) ->
addHeader(object, HttpHeaders.ETAG)),

RESPONSE_BUILDER_TYPE(ofNonStatic(CLASS_RESPONSE_BUILDER, "type", RESPONSE_BUILDER, "Ljavax/ws/rs/core/MediaType;"), (object, arguments) -> {
RESPONSE_BUILDER_TYPE(ofNonStatic(CLASS_RESPONSE_BUILDER, "type", RESPONSE_BUILDER, "Ljakarta/ws/rs/core/MediaType;"), (object, arguments) -> {
arguments.get(0).getPossibleValues().stream()
.map(m -> (MediaType) m).map(m -> m.getType() + '/' + m.getSubtype()).forEach(t -> addContentType(object, t));
return object;
Expand All @@ -136,7 +136,7 @@ enum KnownResponseResultMethod implements IdentifiableMethod {
RESPONSE_BUILDER_VARIANTS_LIST(ofNonStatic(CLASS_RESPONSE_BUILDER, "variants", RESPONSE_BUILDER, LIST), (object, arguments) ->
addHeader(object, HttpHeaders.VARY)),

RESPONSE_BUILDER_VARIANTS_ARRAY(ofNonStatic(CLASS_RESPONSE_BUILDER, "variants", RESPONSE_BUILDER, "[Ljavax/ws/rs/core/Variant;"), (object, arguments) ->
RESPONSE_BUILDER_VARIANTS_ARRAY(ofNonStatic(CLASS_RESPONSE_BUILDER, "variants", RESPONSE_BUILDER, "[Ljakarta/ws/rs/core/Variant;"), (object, arguments) ->
addHeader(object, HttpHeaders.VARY)),

// static methods in Response --------------------------
Expand Down Expand Up @@ -174,7 +174,7 @@ enum KnownResponseResultMethod implements IdentifiableMethod {
return addHeader(object, HttpHeaders.CONTENT_ENCODING);
}),

RESPONSE_OK_MEDIATYPE(ofStatic(CLASS_RESPONSE, "ok", RESPONSE_BUILDER, OBJECT, "Ljavax/ws/rs/core/MediaType;"), (notAvailable, arguments) -> {
RESPONSE_OK_MEDIATYPE(ofStatic(CLASS_RESPONSE, "ok", RESPONSE_BUILDER, OBJECT, "Ljakarta/ws/rs/core/MediaType;"), (notAvailable, arguments) -> {
final Element object = new Element(RESPONSE, new HttpResponse());
addStatus(object, Response.Status.OK.getStatusCode());
arguments.get(1).getPossibleValues().stream().map(m -> (MediaType) m)
Expand Down Expand Up @@ -451,4 +451,4 @@ private static Element addContentType(final Element object, final String type) {
return object;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.sebastian_daschner.jaxrs_analyzer.model.methods.MethodIdentifier;
import org.objectweb.asm.Label;

import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JAXRSAnnotatedSuperMethodClassVisitor extends ClassVisitor {
private final Method method;

JAXRSAnnotatedSuperMethodClassVisitor(final MethodResult methodResult, final Method method) {
super(ASM5);
super(ASM7);
this.methodResult = methodResult;
this.method = method;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.List;
import java.util.Map;

import static org.objectweb.asm.Opcodes.ASM5;
import static org.objectweb.asm.Opcodes.ASM7;

/**
* @author Sebastian Daschner
Expand All @@ -29,7 +29,7 @@ class JAXRSAnnotatedSuperMethodVisitor extends MethodVisitor {
private final BitSet annotatedParameters;

JAXRSAnnotatedSuperMethodVisitor(final MethodResult methodResult) {
super(ASM5);
super(ASM7);
this.methodResult = methodResult;
parameterTypes = methodResult.getOriginalMethodSignature().getParameters();
annotatedParameters = new BitSet(parameterTypes.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.sebastian_daschner.jaxrs_analyzer.model.results.MethodResult;
import org.objectweb.asm.*;

import javax.ws.rs.*;
import jakarta.ws.rs.*;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
Expand All @@ -33,7 +33,7 @@ public class JAXRSClassVisitor extends ClassVisitor {
private final ClassResult classResult;

public JAXRSClassVisitor(final ClassResult classResult) {
super(ASM5);
super(ASM7);
this.classResult = classResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class JAXRSFieldVisitor extends FieldVisitor {
private MethodParameter parameter;

JAXRSFieldVisitor(final ClassResult classResult, final String desc, final String signature) {
super(Opcodes.ASM5);
super(Opcodes.ASM7);
this.classResult = classResult;
this.signature = signature == null ? desc : signature;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ProjectMethodClassVisitor extends ClassVisitor {
private String superName;

public ProjectMethodClassVisitor(final MethodResult methodResult, final MethodIdentifier identifier) {
super(ASM5);
super(ASM7);
this.methodResult = methodResult;
this.identifier = identifier;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProjectMethodVisitor extends MethodVisitor {
private final String className;

ProjectMethodVisitor(MethodResult methodResult, String className) {
super(ASM5);
super(ASM7);
// TODO refactor to list of instructions only
this.methodResult = methodResult;
this.className = className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.sebastian_daschner.jaxrs_analyzer.model.rest.MethodParameter;

/**
* Visits the {@link javax.ws.rs.DefaultValue} annotation and sets the configured value.
* Visits the {@link jakarta.ws.rs.DefaultValue} annotation and sets the configured value.
*
* @author Daryl Teo
* @author Sebastian Daschner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class ValueAnnotationVisitor extends AnnotationVisitor {
private static final String NAME = "value";

ValueAnnotationVisitor() {
super(Opcodes.ASM5);
super(Opcodes.ASM7);
}

protected abstract void visitValue(String value);
Expand All @@ -25,7 +25,7 @@ public void visit(String name, Object value) {

@Override
public AnnotationVisitor visitArray(String name) {
return new AnnotationVisitor(Opcodes.ASM5) {
return new AnnotationVisitor(Opcodes.ASM7) {
@Override
public void visit(String name, Object value) {
visitValue((String) value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier;
import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation;

import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonValue;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.json.JsonValue;
import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import com.sebastian_daschner.jaxrs_analyzer.utils.Pair;
import org.objectweb.asm.Type;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlTransient;
import java.lang.reflect.*;
import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -79,8 +79,8 @@ TypeIdentifier analyze(final String rootType) {
}

private static boolean isJDKType(final String type) {
// exclude java, javax, etc. packages
return Types.PRIMITIVE_TYPES.contains(type) || type.startsWith("Ljava/") || type.startsWith("Ljavax/");
// exclude java, jakarta, etc. packages
return Types.PRIMITIVE_TYPES.contains(type) || type.startsWith("Ljava/") || type.startsWith("Ljakarta/");
}

private TypeRepresentation analyzeInternal(final TypeIdentifier identifier, final String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import com.sebastian_daschner.jaxrs_analyzer.model.elements.JsonObject;
import com.sebastian_daschner.jaxrs_analyzer.model.elements.JsonValue;

import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObjectBuilder;
import jakarta.json.Json;
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonObjectBuilder;
import java.util.Set;
import java.util.function.Function;

Expand All @@ -47,13 +47,13 @@ private JsonMapper() {
* @param jsonValue The JSON value to map
* @return A JSON-P value
*/
static javax.json.JsonValue map(final JsonValue jsonValue) {
static jakarta.json.JsonValue map(final JsonValue jsonValue) {
if (jsonValue instanceof JsonArray)
return map((JsonArray) jsonValue);
return map((JsonObject) jsonValue);
}

private static javax.json.JsonArray map(final JsonArray jsonArray) {
private static jakarta.json.JsonArray map(final JsonArray jsonArray) {
final JsonArrayBuilder builder = Json.createArrayBuilder();
jsonArray.getElements().stream().forEach(e -> addToArray(builder, e));
return builder.build();
Expand All @@ -76,7 +76,7 @@ private static void addToArray(final JsonArrayBuilder builder, final Element val
value.getPossibleValues().stream().filter(v -> v instanceof JsonValue).findFirst().ifPresent(v -> builder.add(map((JsonValue) v)));
}

private static javax.json.JsonObject map(final JsonObject jsonObject) {
private static jakarta.json.JsonObject map(final JsonObject jsonObject) {
final JsonObjectBuilder builder = Json.createObjectBuilder();
jsonObject.getStructure().entrySet().stream().forEach(e -> addToObject(builder, e.getKey(), e.getValue()));
return builder.build();
Expand Down Expand Up @@ -107,7 +107,7 @@ private static void addToObject(final JsonObjectBuilder builder, final String ke
}

// TODO remove unused code, refactor & test types (e.g. Date, JSR-310)
static void addToObject(final JsonObjectBuilder builder, final String key, final String type, final Function<String, javax.json.JsonValue> defaultBehavior) {
static void addToObject(final JsonObjectBuilder builder, final String key, final String type, final Function<String, jakarta.json.JsonValue> defaultBehavior) {
if (STRING.equals(type)) {
builder.add(key, "string");
return;
Expand Down Expand Up @@ -144,7 +144,7 @@ static void addToObject(final JsonObjectBuilder builder, final String key, final
builder.add(key, defaultBehavior.apply(type));
}

static void addToArray(final JsonArrayBuilder builder, final String type, final Function<String, javax.json.JsonValue> defaultBehavior) {
static void addToArray(final JsonArrayBuilder builder, final String type, final Function<String, jakarta.json.JsonValue> defaultBehavior) {
if (STRING.equals(type)) {
builder.add("string");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.sebastian_daschner.jaxrs_analyzer.model.Types;

import javax.ws.rs.core.GenericEntity;
import jakarta.ws.rs.core.GenericEntity;

import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.getTypeParameters;
import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.isAssignableTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ private void updateMethodParameters(final Set<MethodParameter> parameters, final
private void addDefaultResponses(final MethodResult methodResult) {
if (methodResult.getResponses().isEmpty()) {
final HttpResponse httpResponse = new HttpResponse();
httpResponse.getStatuses().add(javax.ws.rs.core.Response.Status.NO_CONTENT.getStatusCode());
httpResponse.getStatuses().add(jakarta.ws.rs.core.Response.Status.NO_CONTENT.getStatusCode());
methodResult.getResponses().add(httpResponse);
return;
}

methodResult.getResponses().stream().filter(r -> r.getStatuses().isEmpty())
.forEach(r -> r.getStatuses().add(javax.ws.rs.core.Response.Status.OK.getStatusCode()));
.forEach(r -> r.getStatuses().add(jakarta.ws.rs.core.Response.Status.OK.getStatusCode()));
}

private void interpretResponse(final HttpResponse httpResponse, final ResourceMethod method) {
Expand Down
Loading