Home  >  Q&A  >  body text

java - 怎么让tomcat使用我自定义的类加载器?

要对web项目的class文件进行混淆,请问在哪配置可以让tomcat先使用自定义的类加载器?

PHP中文网PHP中文网2741 days ago340

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:46:59

    The description of the problem is not very clear
    But I can briefly explain the class loading to you
    a.Bootstrap ClassLoader/Boot class loader
    It is mainly responsible for the core api in the jdk_home/lib directory or the jar package specified by the -Xbootclasspath option.
    b.Extension ClassLoader/Extension Class Loader
    Mainly responsible for the jar package in the jdk_home/lib/ext directory or the jar package in the directory specified by -Djava.ext.dirs
    c.System ClassLoader/System Class Loader
    Mainly responsible for java -classpath/-The classes and jar packages in the directory pointed to by Djava.class.path are included in the work.
    d.User Custom ClassLoader/User-defined class loader (a subclass of java.lang.ClassLoader)
    When the program is running During this period, the class file is dynamically loaded through the subclass of java.lang.ClassLoader, reflecting the dynamic real-time class loading feature of java

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 17:46:59

    Tomcat uses WebappClassLoader to load the app, but I don’t see server.xml opening this interface. If you want to replace it, you need to modify the tomcat source code.

    There is also a better solution, use java agent to dynamically replace the class, so that the class can be encrypted and decrypted.

    reply
    0
  • Cancelreply