Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparation for adding camel #993

Closed
wants to merge 1 commit into from
Closed
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
40 changes: 28 additions & 12 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Copyright 2018 Red Hat, Inc. ~ ~ 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
<!-- ~ Copyright 2018 Red Hat, Inc. ~ ~ 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. -->

<project xmlns="http://maven.apache.org/POM/4.0.0"
Expand All @@ -26,7 +26,7 @@
<properties>
<!-- Enable APT by default for Eclipse -->
<m2e.apt.activation>jdt_apt</m2e.apt.activation>

<aesh.version>1.11</aesh.version>
<jandex.version>2.1.1.Final</jandex.version>
<resteasy.version>4.0.0.Beta8</resteasy.version>
Expand Down Expand Up @@ -67,10 +67,10 @@
<plexus-utils.version>3.0.24</plexus-utils.version>
<maven-plugin-annotations.version>3.5.2</maven-plugin-annotations.version>
<plexus-component-annotations.version>1.7.1</plexus-component-annotations.version>
<!-- What we actually depend on for the annotations, as latest Graal
<!-- What we actually depend on for the annotations, as latest Graal
is not available in Maven fast enough: -->
<graal-sdk.version>1.0.0-rc12</graal-sdk.version>
<!-- The Graal version we suggest using in documentation - as that's
<!-- The Graal version we suggest using in documentation - as that's
what we work with by self downloading it: -->
<graal-sdk.version-for-documentation>1.0.0-rc12</graal-sdk.version-for-documentation>
<gizmo.version>1.0.0.Alpha1</gizmo.version>
Expand Down Expand Up @@ -169,6 +169,7 @@
<artifactId>shamrock-caffeine-runtime</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-devtools-common</artifactId>
Expand Down Expand Up @@ -403,6 +404,16 @@
<artifactId>shamrock-openssl-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-jaxb-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-jaxb-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-rest-client-deployment</artifactId>
Expand Down Expand Up @@ -958,7 +969,7 @@
<artifactId>maven-settings-builder</artifactId>
<version>${maven-core.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
Expand Down Expand Up @@ -997,7 +1008,7 @@
<version>${test-containers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
Expand Down Expand Up @@ -1368,6 +1379,11 @@
<artifactId>infinispan-query-dsl</artifactId>
<version>${infinispan.version}</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-commons</artifactId>
<version>${infinispan.version}</version>
</dependency>

<dependency>
<groupId>org.reactivestreams</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public final class ErrorReplacingProcessReader implements Runnable {
private final File reportdir;
private final CountDownLatch doneLatch;

private ReportAnalyzer reportAnalyzer;

public ErrorReplacingProcessReader(InputStream inputStream, File reportdir, CountDownLatch doneLatch) {
this.inputStream = inputStream;
this.reportdir = reportdir;
Expand Down Expand Up @@ -97,7 +99,7 @@ public void run() {
}
}

private static void handleErrorState(File report, String firstLine, Deque<String> queue) {
private void handleErrorState(File report, String firstLine, Deque<String> queue) {
System.err.println(firstLine);
String remainder = firstLine.substring(LINE_START.length());
Matcher m = Pattern.compile("([^(]*).*").matcher(remainder);
Expand Down Expand Up @@ -127,8 +129,10 @@ private static void handleErrorState(File report, String firstLine, Deque<String
int idex = fullName.lastIndexOf('.');
String clazz = fullName.substring(0, idex);
String method = fullName.substring(idex + 1);

System.err.println(ReportAnalyzer.analyse(report.getAbsolutePath(), clazz, method));
if(reportAnalyzer == null) {
reportAnalyzer = new ReportAnalyzer(report.getAbsolutePath());
}
System.err.println(reportAnalyzer.analyse(clazz, method));
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,81 @@

public class ReportAnalyzer {

final List<Node> parents = new ArrayList<>();
final Map<String, List<Node>> byClassMap = new HashMap<>();
final Map<String, List<Node>> constructors = new HashMap<>();

static Pattern PATTERN = Pattern.compile("(.*?)([^\\s(]+)\\.([^.]+\\(.*?\\):[^\\s])");

public ReportAnalyzer(String report) {
try {
Deque<String> lines = new ArrayDeque<>();
try (BufferedReader in = Files.newBufferedReader(Paths.get(report))) {
for (String re = in.readLine(); re != null; re = in.readLine()) {
lines.add(re);
}
}

String first = lines.pop();
if (!first.equals("VM Entry Points")) {
throw new IllegalArgumentException("Unexpected first line in file " + first);
}
Node last = null;
for (String line : lines) {
if (line.trim().isEmpty()) {
continue;
}
int start = 0;
int lc = 0;
for (; start < line.length(); ++start) {
char c = line.charAt(start);
if (c == '├' || c == '└') {
break;
} else {
lc++;
}
}
if (line.length() < start + 3) {
continue;
}
Matcher matcher = PATTERN.matcher(line.substring(start + 3));
if (!matcher.find()) {
throw new RuntimeException("Failed " + line);
}
String type = matcher.group(1).trim();
String clz = matcher.group(2);
String method = matcher.group(3);
Node parent;
if (last == null) {
parent = null;
} else if (last.indent < lc) {
parent = last;
} else {
parent = last;
while (parent != null) {
parent = parent.parent;
if (parent == null || parent.indent < lc) {
break;
}
}
}
Node n = new Node(lc, type, clz, method, parent);
if (parent == null) {
parents.add(n);
} else {
n.parent.children.add(n);
}
byClassMap.computeIfAbsent(clz, (k) -> new ArrayList<>()).add(n);
if (method.startsWith("<init>")) {
constructors.computeIfAbsent(clz, (k) -> new ArrayList<>()).add(n);
}
last = n;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

/**
* Analyze the contents of the call tree report produced by Substrate when using -H:+PrintAnalysisCallTree,
* and does a more meaningful analysis of what is causing a type to be retained.
Expand All @@ -50,72 +122,8 @@ public class ReportAnalyzer {
* is abandoned, and instead the call flow for the constructor of the current object is printed instead.
*
*/
public static String analyse(String report, String className, String methodName) throws Exception {
Deque<String> lines = new ArrayDeque<>();
try (BufferedReader in = Files.newBufferedReader(Paths.get(report))) {
for (String re = in.readLine(); re != null; re = in.readLine()) {
lines.add(re);
}
}
public String analyse(String className, String methodName) throws Exception {

String first = lines.pop();
if (!first.equals("VM Entry Points")) {
throw new IllegalArgumentException("Unexpected first line in file " + first);
}
List<Node> parents = new ArrayList<>();
Map<String, List<Node>> byClassMap = new HashMap<>();
Map<String, List<Node>> constructors = new HashMap<>();
Node last = null;
for (String line : lines) {
if (line.trim().isEmpty()) {
continue;
}
int start = 0;
int lc = 0;
for (; start < line.length(); ++start) {
char c = line.charAt(start);
if (c == '├' || c == '└') {
break;
} else {
lc++;
}
}
if (line.length() < start + 3) {
continue;
}
Matcher matcher = PATTERN.matcher(line.substring(start + 3));
if (!matcher.find()) {
throw new RuntimeException("Failed " + line);
}
String type = matcher.group(1).trim();
String clz = matcher.group(2);
String method = matcher.group(3);
Node parent;
if (last == null) {
parent = null;
} else if (last.indent < lc) {
parent = last;
} else {
parent = last;
while (parent != null) {
parent = parent.parent;
if (parent == null || parent.indent < lc) {
break;
}
}
}
Node n = new Node(lc, type, clz, method, parent);
if (parent == null) {
parents.add(n);
} else {
n.parent.children.add(n);
}
byClassMap.computeIfAbsent(clz, (k) -> new ArrayList<>()).add(n);
if (method.startsWith("<init>")) {
constructors.computeIfAbsent(clz, (k) -> new ArrayList<>()).add(n);
}
last = n;
}

List<Node> dm = byClassMap.getOrDefault(className, new ArrayList<>()).stream().filter((s) -> s.method.startsWith(methodName + "(")).collect(Collectors.toList());

Expand All @@ -129,16 +137,16 @@ public static String analyse(String report, String className, String methodName)
StringBuilder sb = new StringBuilder();
while (!runQueue.isEmpty()) {
Node current = runQueue.pop();
sb.append("Possible path to " + current.className + "." + current.method);
sb.append("Possible path to " + current.className + "." + current.method +"\n");
while (current != null) {
sb.append("\t" + current.className + "." + current.method + '\n');

String reason = null;
if(current.parent == null || current.parent.children.size() > 1) {
if (current.type.equals("is overridden by")) {
reason = "This is an implementation of " + current.parent.className + " printing path to constructors of " + current.className;
reason = "This is an implementation of " + current.parent.className + " printing path to constructors of " + current.className+"\n";
} else if (current.type.equals("is implemented by")) {
reason = "This is an implementation of " + current.parent.className + " printing path to constructors of " + current.className;
reason = "This is an implementation of " + current.parent.className + " printing path to constructors of " + current.className+"\n";
}
}
if (reason != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class Target_org_slf4j_LoggerFactory {
public static Logger getLogger(Class<?> clazz) {
return LoggerFactory.getLogger(clazz.getName());
}

}

@TargetClass(InitialConfigurator.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
/*
* Copyright 2018 Red Hat, Inc.
*
* 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.jboss.shamrock.resteasy.common.runtime.graal;
package org.jboss.shamrock.runtime.graal;

import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
Expand All @@ -24,7 +8,6 @@
import java.io.OutputStream;
import java.net.URL;
import java.util.Iterator;

import javax.imageio.ImageReader;
import javax.imageio.ImageTranscoder;
import javax.imageio.ImageTypeSpecifier;
Expand All @@ -35,9 +18,8 @@
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;


@TargetClass(className = "javax.imageio.ImageIO")
final class ImageIOSubstitutions {
final class Target_javax_imageio_ImageIO {

@Substitute
public static void scanForPlugins() {
Expand Down Expand Up @@ -207,4 +189,4 @@ public static boolean write(RenderedImage im,
OutputStream output) throws IOException {
throw new IOException("Not Implemented yet on substrate");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
/*
* Copyright 2018 Red Hat, Inc.
*
* 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.jboss.shamrock.resteasy.common.runtime.graal;
package org.jboss.shamrock.runtime.graal;

import java.awt.color.ICC_Profile;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "sun.java2d.cmm.lcms.LCMS")
final class LCMSSubstitutions {
final class Target_sun_java2d_cmm_lcms_LCMS {

@Substitute
private long loadProfileNative(byte[] data, Object ref) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
for (File i : files) {
if (i.getName().startsWith("call_tree")) {
try {
System.out.println(ReportAnalyzer.analyse(i.getAbsolutePath(), clazz, method));
System.out.println(new ReportAnalyzer(i.getAbsolutePath()).analyse(clazz, method));
} catch (Exception e) {
throw new MojoExecutionException("Failed", e);
}
Expand Down
Loading