• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
today-context/src/main/java/infra/instrument/classloading/SimpleInstrumentableClassLoader.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.instrument.classloading;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.lang.instrument.ClassFileTransformer;
23

24
import infra.core.OverridingClassLoader;
25

26
/**
27
 * Simplistic implementation of an instrumentable {@code ClassLoader}.
28
 *
29
 * <p>Usable in tests and standalone environments.
30
 *
31
 * @author Rod Johnson
32
 * @author Costin Leau
33
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
34
 * @since 4.0
35
 */
36
public class SimpleInstrumentableClassLoader extends OverridingClassLoader {
37

38
  static {
39
    ClassLoader.registerAsParallelCapable();
2✔
40
  }
1✔
41

42
  private final WeavingTransformer weavingTransformer;
43

44
  /**
45
   * Create a new SimpleInstrumentableClassLoader for the given ClassLoader.
46
   *
47
   * @param parent the ClassLoader to build an instrumentable ClassLoader for
48
   */
49
  public SimpleInstrumentableClassLoader(@Nullable ClassLoader parent) {
50
    super(parent);
3✔
51
    this.weavingTransformer = new WeavingTransformer(parent);
6✔
52
  }
1✔
53

54
  /**
55
   * Add a {@link ClassFileTransformer} to be applied by this ClassLoader.
56
   *
57
   * @param transformer the {@link ClassFileTransformer} to register
58
   */
59
  public void addTransformer(ClassFileTransformer transformer) {
60
    this.weavingTransformer.addTransformer(transformer);
4✔
61
  }
1✔
62

63
  @Override
64
  protected byte[] transformIfNecessary(String name, byte[] bytes) {
65
    return this.weavingTransformer.transformIfNecessary(name, bytes);
×
66
  }
67

68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc