Skip to content

Commit

Permalink
Debug ClassBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
prdoyle committed Jul 6, 2024
1 parent bc30e04 commit c305b95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bosk-core/src/main/java/works/bosk/bytecode/ClassBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import works.bosk.exceptions.NotYetImplementedException;
import works.bosk.util.ReflectionHelpers;

import static java.lang.System.identityHashCode;
import static java.lang.reflect.Modifier.isStatic;
import static java.util.Collections.synchronizedMap;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -203,7 +204,7 @@ public void invokeDynamic(String name, CallSite callSite) {
String fullName = "CallSite_" + CALL_SITE_COUNT.incrementAndGet() + "_" + name;

CALL_SITES_BY_NAME.put(fullName, callSite);
LOGGER.debug("Added call site ({})", name);
LOGGER.debug("Added call site \"{}\" {}", fullName, identityHashCode(callSite));

methodVisitor().visitInvokeDynamicInsn(
fullName,
Expand Down Expand Up @@ -418,8 +419,9 @@ public Class<?> loadThemBytes(String dottyName, byte[] b) {
// happens-before edge between when the call site is added and when we remove it.

public static CallSite retrieveCallSite(MethodHandles.Lookup __, String name, MethodType ___) {
LOGGER.debug("retrieveCallSite({})", name);
return requireNonNull(CALL_SITES_BY_NAME.remove(name));
CallSite callSite = CALL_SITES_BY_NAME.remove(name);
LOGGER.debug("Retrieved call site \"{}\" {}", name, identityHashCode(callSite));
return requireNonNull(callSite);
}

private static final Method RETRIEVE_CALL_SITE_METHOD;
Expand Down
1 change: 1 addition & 0 deletions lib-testing/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<!-- This emits warnings that matter in production but not in tests -->
<logger name="works.bosk.drivers.mongo.UninitializedCollectionException" level="ERROR"/>
<logger name="works.bosk.bytecode.ClassBuilder" level="DEBUG"/>

<!-- How to add more tracing during unit tests
<logger name="works.bosk.drivers.mongo" level="DEBUG"/>
Expand Down

0 comments on commit c305b95

Please sign in to comment.