Unten habe ich die Fehler pom.xml, MANIFEST.MF und Agent.java aufgelistet.
Was muss ich tun, um Fehler zu beheben?
Fehler
Code: Select all
[ERROR] /C:/Users/xxxx/eclipse-workspace-2025/mvn/src/main/java/pkt/mvn/Agent.java:[3,27] package net.bytebuddy.agent.builder is not visible
(package net.bytebuddy.agent.builder is declared in the unnamed module, but module java.base does not read it)
[ERROR] /C:/Users/xxxx/eclipse-workspace-2025/mvn/src/main/java/pkt/mvn/Agent.java:[4,33] package net.bytebuddy.description.type is not visible
(package net.bytebuddy.description.type is declared in the unnamed module, but module java.base does not read it)
[ERROR] /C:/Users/xxxx/eclipse-workspace-2025/mvn/src/main/java/pkt/mvn/Agent.java:[5,21] package net.bytebuddy.dynamic is not visible
(package net.bytebuddy.dynamic is declared in the unnamed module, but module java.base does not read it)
[ERROR] /C:/Users/xxxx/eclipse-workspace-2025/mvn/src/main/java/pkt/mvn/Agent.java:[6,21] package net.bytebuddy.implementation is not visible
(package net.bytebuddy.implementation is declared in the unnamed module,  b u t   m o d u l e   j a v a . b a s e   d o e s   n o t   r e a d   i t ) < b r   / > [ E R R O R ]   / C : / U s e r s / x x x x / e c l i p s e - w o r k s p a c e - 2 0 2 5 / m v n / s r c / m a i n / j a v a / p k t / m v n / A g e n t . j a v a : [ 7 , 2 1 ]   p a c k a g e   n e t . b y t e b u d d y . m a t c h e r   i s   n o t   v i s i b l e < b r   / > < / c o d e > < b r   / > < h 1 > < s t r o n g > p o m . x m l < / s t r o n g > < / h 1 > < b r   / > < p r e   c l a s s = " l a n g - x m l   P r e t t y p r i n t - o v e r r i d e " > < c o d e > & l t ; p r o j e c t   x m l n s = & q u o t ; h t t p : / / m a v e n . a p a c h e . o r g / P O M / 4 . 0 . 0 & q u o t ; < b r   / >         x m l n s : x s i = & q u o t ; h t t p : / / w w w . w 3 . o r g / 2 0 0 1 / X M L S c h e m a - i n s t a n c e & q u o t ; < b r   / >         x s i : s c h e m a L o c a t i o n = & q u o t ; h t t p : / / m a v e n . a p a c h e . o r g / P O M / 4 . 0 . 0   h t t p : / / m a v e n . a p a c h e . o r g / x s d / m a v e n - 4 . 0 . 0 . x s d & q u o t ; & g t ; < b r   / >         & l t ; m o d e l V e r s i o n & g t ; 4 . 0 . 0 & l t ; / m o d e l V e r s i o n & g t ; < b r   / > < b r   / >         & l t ; g r o u p I d & g t ; p k t & l t ; / g r o u p I d & g t ; < b r   / >         & l t ; a r t i f a c t I d & g t ; m v n & l t ; / a r t i f a c t I d & g t ; < b r   / >         & l t ; v e r s i o n & g t ; 0 . 0 . 1 - S N A P S H O T & l t ; / v e r s i o n & g t ; < b r   / >         & l t ; p a c k a g i n g & g t ; j a r & l t ; / p a c k a g i n g & g t ; < b r   / > < b r   / >         & l t ; n a m e & g t ; m v n & l t ; / n a m e & g t ; < b r   / >         & l t ; u r l & g t ; h t t p : / / m a v e n . a p a c h e . o r g & l t ; / u r l & g t ; < b r   / > < b r   / >         & l t ; p r o p e r t i e s & g t ; < b r   / >                 & l t ; m a v e n . c o m p i l e r . s o u r c e & g t ; 2 2 & l t ; / m a v e n . c o m p i l e r . s o u r c e & g t ; < b r   / >                 & l t ; m a v e n . c o m p i l e r . t a r g e t & g t ; 2 2 & l t ; / m a v e n . c o m p i l e r . t a r g e t & g t ; < b r   / >                 & l t ; p r o j e c t . b u i l d . s o u r c e E n c o d i n g & g t ; U T F - 8 & l t ; / p r o j e c t . b u i l d . s o u r c e E n c o d i n g & g t ; < b r   / >                 & l t ; b y t e b u d d y . v e r s i o n & g t ; 1 . 1 4 . 8 & l t ; / b y t e b u d d y . v e r s i o n & g t ; < b r   / >         & l t ; / p r o p e r t i e s & g t ; < b r  />    
junit
junit
3.8.1
test
net.bytebuddy
byte-buddy
${bytebuddy.version}
net.bytebuddy
byte-buddy-agent
${bytebuddy.version}
org.springframework
spring-core
6.0.4
my-repo2
your custom repo
http://jarsm2.dyndns.dk
org.apache.maven.plugins
maven-jar-plugin
3.3.0
true
true
true
pkt.mvn.Agent
false
true
pkt.mvn.App
org.apache.maven.plugins
maven-compiler-plugin
3.12.1
--add-exports
java.base/sun.security.util=ALL-UNNAMED
--add-exports
java.base/sun.security.jca=ALL-UNNAMED
--add-exports
java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports
java.base/sun.security.internal.interfaces=ALL-UNNAMED
--add-exports
java.base/sun.security.provider.certpath=ALL-UNNAMED
--add-exports
java.base/sun.security.internal.spec=ALL-UNNAMED
--add-exports
java.base/sun.security.validator=ALL-UNNAMED
--add-exports
java.base/sun.security.action=ALL-UNNAMED
--add-exports
java.base/sun.security.x509=ALL-UNNAMED
--patch-module=java.base=${basedir}/src/main/java
*
Code: Select all
Premain-Class:  pkt.mvn.Agent
Agent-Class: pkt.mvn.Agent
Can-Redefine-Classes: true
Can-Retransform-Classes: true
Main-Class: pkt.mvn.App
Code: Select all
package pkt.mvn;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.matcher.ElementMatchers;
import net.bytebuddy.utility.JavaModule;
import java.io.*;
import java.lang.instrument.Instrumentation;
import java.nio.file.Files;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import pkt.mvn.*;
/**
* Java agent that injects OurECParameters into the bootstrap class loader and
* redefines sun.security.util.ECParameters to delegate logic to
* OurECParameters.
*/
public class Agent {
public static void premain(String agentArgs, Instrumentation inst) throws ClassNotFoundException {
try {
System.out.println("[agent] premain starting");
// Create a temporary jar that contains our helper class (OurECParameters)
Class cls = Class.forName("pkt.mvn.ECParameters");
File tmpJar = createBootstrapJarContaining(cls);
System.out.println("[agent] created bootstrap jar at: " + tmpJar);
// Make the jar available to bootstrap class loader so core classes can
// reference OurECParameters
inst.appendToBootstrapClassLoaderSearch(new java.util.jar.JarFile(tmpJar));
System.out.println("[agent] appended to bootstrap class loader search");
// Use Byte Buddy to retransform/redefine the JDK internal class
new AgentBuilder.Default().with(AgentBuilder.RedefinitionStrategy.REDEFINITION)
.type(ElementMatchers.nameEndsWith("sun.security.util.ECParameters")
.or(ElementMatchers.named("sun.security.util.ECParameters")))
.transform((builder, typeDescription, classLoader, module, protectionDomain) -> {
System.out.println("[agent] transforming: " + typeDescription.getName());
//--return builder.method(ElementMatchers.not(ElementMatchers.isPrivate()))
//--        .intercept(MethodDelegation.to(Class.forName("pkt.ECParameters.class", true, null)));
return builder.method(ElementMatchers.any()).intercept(MethodDelegation.to(cls)) ;
}).installOn(inst);
// Optionally retransform already loaded class if it is already loaded:
for (Class c : inst.getAllLoadedClasses()) {
if ("sun.security.util.ECParameters".equals(c.getName()) && inst.isModifiableClass(c)) {
try {
System.out.println("[agent] retransfoming already-loaded ECParameters");
inst.retransformClasses(c);
} catch (Throwable t) {
System.out.println("[agent] retransformation failed: " + t);
}
}
}
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
System.out.println("[agent] premain finished");
}
/**
* Create a temporary JAR containing the given class (and related nested
* classes).  We read the class bytes from the agent's own classloader resources
* and write into temp jar.
*/
private static File createBootstrapJarContaining(Class cls) throws IOException {
String resourcePath = cls.getName().replace('.', '/') + ".class";
InputStream classStream = cls.getClassLoader().getResourceAsStream(resourcePath);
if (classStream == null) {
throw new IllegalStateException("Cannot find class resource: " + resourcePath);
}
File tmpJar = Files.createTempFile("agent-bootstrap-", ".jar").toFile();
tmpJar.deleteOnExit();
try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(tmpJar))) {
JarEntry entry = new JarEntry(resourcePath);
jos.putNextEntry(entry);
byte[] buffer = new byte[8192];
int r;
while ((r = classStream.read(buffer)) != -1) {
jos.write(buffer, 0, r);
}
jos.closeEntry();
}
return tmpJar;
}
}
 Mobile version
 Mobile version