Skip to content

Commit

Permalink
Fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Oct 22, 2024
1 parent e4440a0 commit 254bba3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 110 deletions.
3 changes: 2 additions & 1 deletion src/it/projects/github322/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
* under the License.
*/

new IntegrationBase().checkExistenceAndContentOfAFile(new File( basedir, "build.log" ), [ "Main Result: <null>" ])
File log = new File(basedir, 'build.log')
assert log.text.contains( 'Main Result: <null>')
2 changes: 1 addition & 1 deletion src/it/projects/mexec-29/invoker.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
invoker.goals = clean verify

invoker.debug = true
invoker.buildResult = success
invoker.buildResult = failure
168 changes: 60 additions & 108 deletions src/main/java/org/codehaus/mojo/exec/URLClassLoaderBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import static java.util.Arrays.asList;

/**
*
* @author Robert Scholte
* @since 3.0.0
*/
Expand All @@ -60,14 +59,12 @@ static URLClassLoaderBuilder builder() {
return new URLClassLoaderBuilder();
}

URLClassLoaderBuilder setExcludedJvmPackages(List<String> excludedJvmPackages )
{
URLClassLoaderBuilder setExcludedJvmPackages(List<String> excludedJvmPackages) {
this.excludedJvmPackages = excludedJvmPackages;
return this;
}

URLClassLoaderBuilder setForcedJvmPackages(List<String> forcedJvmPackages )
{
URLClassLoaderBuilder setForcedJvmPackages(List<String> forcedJvmPackages) {
this.forcedJvmPackages = forcedJvmPackages;
return this;
}
Expand Down Expand Up @@ -110,7 +107,7 @@ URLClassLoader build() throws IOException {
}
}

return new ExecJavaClassLoader( urls.toArray( new URL[0] ), transformer, logger, forcedJvmPackages, excludedJvmPackages );
return new ExecJavaClassLoader(urls.toArray(new URL[0]), transformer, forcedJvmPackages, excludedJvmPackages);
}

// child first strategy
Expand All @@ -124,16 +121,17 @@ private static class ExecJavaClassLoader extends URLClassLoader {
}

private final String jre;
private final Log logger;
private final ClassFileTransformer transformer;
private final List<String> forcedJvmPackages;
private final List<String> excludedJvmPackages;

public ExecJavaClassLoader(URL[] urls, ClassFileTransformer transformer, Log logger, List<String> forcedJvmPackages, List<String> excludedJvmPackages )
{
public ExecJavaClassLoader(
URL[] urls,
ClassFileTransformer transformer,
List<String> forcedJvmPackages,
List<String> excludedJvmPackages) {
super(urls);
this.jre = getJre();
this.logger = logger;
this.transformer = transformer;
this.forcedJvmPackages = forcedJvmPackages;
this.excludedJvmPackages = excludedJvmPackages;
Expand Down Expand Up @@ -328,151 +326,104 @@ private boolean postLoad(boolean resolve, Class<?> clazz) {

// not all jvm classes, for ex "javax" can be overridden so don't list it them all here (javax.resource for ex)
private boolean isDirectJvmClass(final String name) {
if (excludedJvmPackages != null && excludedJvmPackages.stream().anyMatch( name::startsWith ))
{
if (excludedJvmPackages != null && excludedJvmPackages.stream().anyMatch(name::startsWith)) {
return false;
}
if (name.startsWith( "java." ) )
{
if (name.startsWith("java.")) {
return true;
}
if ( name.startsWith( "sun." ) )
{
} else if (name.startsWith("javax.")) {
final String sub = name.substring("javax.".length());
if (sub.startsWith("xml.")) {
return true;
}
} else if (name.startsWith("sun.")) {
return true;
}
if ( name.startsWith( "jdk." ) )
{
} else if (name.startsWith("jdk.")) {
return true;
}
if ( name.startsWith( "oracle." ) )
{
} else if (name.startsWith("oracle.")) {
return true;
}
if ( name.startsWith( "javafx." ) )
{
} else if (name.startsWith("javafx.")) {
return true;
}
if ( name.startsWith( "netscape." ) )
{
} else if (name.startsWith("netscape.")) {
return true;
}
if ( name.startsWith( "org." ) )
{
final String sub = name.substring( "org.".length() );
if ( sub.startsWith( "w3c.dom." ) )
{
} else if (name.startsWith("org.")) {
final String sub = name.substring("org.".length());
if (sub.startsWith("w3c.dom.")) {
return true;
}
if ( sub.startsWith( "omg." ) )
{
} else if (sub.startsWith("omg.")) {
return true;
}
if ( sub.startsWith( "xml.sax." ) )
{
} else if (sub.startsWith("xml.sax.")) {
return true;
}
if ( sub.startsWith( "ietf.jgss." ) )
{
} else if (sub.startsWith("ietf.jgss.")) {
return true;
}
if ( sub.startsWith( "jcp.xml.dsig.internal." ) )
{
} else if (sub.startsWith("jcp.xml.dsig.internal.")) {
return true;
}
}
if ( name.startsWith( "com." ) )
{
final String sub = name.substring( "com.".length() );
if ( sub.startsWith( "oracle." ) )
{
} else if (name.startsWith("com.")) {
final String sub = name.substring("com.".length());
if (sub.startsWith("oracle.")) {
return true;
}
if ( sub.startsWith( "sun." ) )
{
final String subSun = sub.substring( "sun.".length() );
if ( subSun.startsWith( "accessibility." ) )
{
} else if (sub.startsWith("sun.")) {
final String subSun = sub.substring("sun.".length());
if (subSun.startsWith("accessibility.")) {
return true;
}
if (subSun.startsWith("activation.")) {
} else if (subSun.startsWith("activation.")) {
return true;
}
if (subSun.startsWith("awt.")) {
} else if (subSun.startsWith("awt.")) {
return true;
}
if (subSun.startsWith("beans.")) {
} else if (subSun.startsWith("beans.")) {
return true;
}
if (subSun.startsWith("corba.se.")) {
} else if (subSun.startsWith("corba.se.")) {
return true;
}
if (subSun.startsWith("demo.jvmti.")) {
} else if (subSun.startsWith("demo.jvmti.")) {
return true;
}
if (subSun.startsWith("image.codec.jpeg.")) {
} else if (subSun.startsWith("image.codec.jpeg.")) {
return true;
}
if (subSun.startsWith("imageio.")) {
} else if (subSun.startsWith("imageio.")) {
return true;
}
if (subSun.startsWith("istack.internal.")) {
} else if (subSun.startsWith("istack.internal.")) {
return true;
}
if (subSun.startsWith("java.")) {
} else if (subSun.startsWith("java.")) {
return true;
}
if (subSun.startsWith("java_cup.")) {
} else if (subSun.startsWith("java_cup.")) {
return true;
}
if (subSun.startsWith("jmx.")) {
} else if (subSun.startsWith("jmx.")) {
return true;
}
if (subSun.startsWith("jndi.")) {
} else if (subSun.startsWith("jndi.")) {
return true;
}
if (subSun.startsWith("management.")) {
} else if (subSun.startsWith("management.")) {
return true;
}
if (subSun.startsWith("media.sound.")) {
} else if (subSun.startsWith("media.sound.")) {
return true;
}
if (subSun.startsWith("naming.internal.")) {
} else if (subSun.startsWith("naming.internal.")) {
return true;
}
if (subSun.startsWith("net.")) {
} else if (subSun.startsWith("net.")) {
return true;
}
if (subSun.startsWith("nio.")) {
} else if (subSun.startsWith("nio.")) {
return true;
}
if (subSun.startsWith("org.")) {
} else if (subSun.startsWith("org.")) {
return true;
}
if (subSun.startsWith("rmi.rmid.")) {
} else if (subSun.startsWith("rmi.rmid.")) {
return true;
}
if (subSun.startsWith("rowset.")) {
} else if (subSun.startsWith("rowset.")) {
return true;
}
if (subSun.startsWith("security.")) {
} else if (subSun.startsWith("security.")) {
return true;
}
if (subSun.startsWith("swing.")) {
} else if (subSun.startsWith("swing.")) {
return true;
}
if (subSun.startsWith("tracing.")) {
} else if (subSun.startsWith("tracing.")) {
return true;
}
if (subSun.startsWith("xml.internal.")) {
} else if (subSun.startsWith("xml.internal.")) {
return true;
}
}
}
return forcedJvmPackages != null && forcedJvmPackages.stream().anyMatch( name::startsWith );
return forcedJvmPackages != null && forcedJvmPackages.stream().anyMatch(name::startsWith);
}

private class FilteringUrlEnum implements Enumeration<URL> {
private final Enumeration<URL> delegate;

private URL next;

private FilteringUrlEnum(Enumeration<URL> delegate) {
Expand All @@ -498,6 +449,7 @@ public URL nextElement() {

private static class ChainedEnumerations implements Enumeration<URL> {
private final Iterator<Enumeration<URL>> enumerations;

private Enumeration<URL> current;

private ChainedEnumerations(Iterator<Enumeration<URL>> enumerations) {
Expand Down

0 comments on commit 254bba3

Please sign in to comment.