Java Code Examples for com.google.common.reflect.Reflection#initialize()
The following examples show how to use
com.google.common.reflect.Reflection#initialize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TroublesomeBytecodeMisc.java From glowroot with Apache License 2.0 | 5 votes |
@Override public void execute1() { IsolatedWeavingClassLoader loader = (IsolatedWeavingClassLoader) getClass().getClassLoader(); byte[] bytes = generateTroublesomeBytecode(); Class<?> clazz = loader.weaveAndDefineClass("TroublesomeBytecode", bytes, null); Reflection.initialize(clazz); }
Example 2
Source File: JavaagentMain.java From glowroot with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { // this is needed on Java 9+ now that sun.boot.class.path no longer exists, so that // instrumentation config auto complete can find this class in InstrumentationConfigIT Reflection.initialize(Container.class); int port = Integer.parseInt(args[0]); final SocketHeartbeat socketHeartbeat = new SocketHeartbeat(port); new Thread(socketHeartbeat).start(); int javaagentServicePort = Integer.parseInt(args[1]); JavaagentServiceImpl javaagentService = new JavaagentServiceImpl(); final EventLoopGroup bossEventLoopGroup = EventLoopGroups.create("Glowroot-IT-Harness*-GRPC-Boss-ELG"); final EventLoopGroup workerEventLoopGroup = EventLoopGroups.create("Glowroot-IT-Harness*-GRPC-Worker-ELG"); // need at least 2 threads, one for executeApp(), and another for handling interruptApp() at // the same time final ExecutorService executor = Executors.newCachedThreadPool( new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat("Glowroot-IT-Harness*-GRPC-Executor-%d") .build()); final Server server = NettyServerBuilder.forPort(javaagentServicePort) .bossEventLoopGroup(bossEventLoopGroup) .workerEventLoopGroup(workerEventLoopGroup) .executor(executor) .addService(javaagentService.bindService()) .build() .start(); javaagentService.setServerCloseable(new Callable</*@Nullable*/ Void>() { @Override public @Nullable Void call() throws Exception { server.shutdown(); if (!server.awaitTermination(10, SECONDS)) { throw new IllegalStateException("Could not terminate channel"); } executor.shutdown(); if (!executor.awaitTermination(10, SECONDS)) { throw new IllegalStateException("Could not terminate executor"); } if (!bossEventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) { throw new IllegalStateException( "Could not terminate gRPC boss event loop group"); } if (!workerEventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) { throw new IllegalStateException( "Could not terminate gRPC worker event loop group"); } socketHeartbeat.close(); return null; } }); // spin a bit to so that caller can capture a trace with <multiple root nodes> if desired for (int i = 0; i < 1000; i++) { timerMarkerOne(); timerMarkerTwo(); MILLISECONDS.sleep(1); } // non-daemon threads started above keep jvm alive after main returns MILLISECONDS.sleep(Long.MAX_VALUE); }
Example 3
Source File: JsrMethodMisc.java From glowroot with Apache License 2.0 | 4 votes |
@Override public String executeWithReturn() { Reflection.initialize(BundleDbPersistenceManager.class); return ""; }
Example 4
Source File: BytecodeWithStackFramesMisc.java From glowroot with Apache License 2.0 | 4 votes |
@Override public String executeWithReturn() { Reflection.initialize(Buffers.class); return ""; }