Skip to content

Commit

Permalink
Fix DefaultExternalHooks copy methods
Browse files Browse the repository at this point in the history
InvalidationProfiler was added to the ExternalHooks interface in fb8e03e, but the default implementation didn't support passing around an instance of InvalidationProfile. This commit fixes it.
  • Loading branch information
dragos committed Apr 18, 2023
1 parent c34dce5 commit c071d34
Showing 1 changed file with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ public class DefaultExternalHooks implements ExternalHooks {
private Optional<ExternalHooks.Lookup> lookup = Optional.empty();
private Optional<ClassFileManager> classFileManager = Optional.empty();
private GetProvenance getProvenance = NoProvenance.INSTANCE;
private InvalidationProfiler invalidationProfiler = InvalidationProfiler.EMPTY.INSTANCE;

public DefaultExternalHooks(
Optional<ExternalHooks.Lookup> lookup,
Optional<ClassFileManager> classFileManager,
GetProvenance getProvenance
Optional<ExternalHooks.Lookup> lookup,
Optional<ClassFileManager> classFileManager,
GetProvenance getProvenance,
InvalidationProfiler invalidationProfiler
) {
this.lookup = lookup;
this.classFileManager = classFileManager;
this.getProvenance = getProvenance;
this.invalidationProfiler = invalidationProfiler;
}
public DefaultExternalHooks(
Optional<ExternalHooks.Lookup> lookup,
Optional<ClassFileManager> classFileManager,
GetProvenance getProvenance
) {
this(lookup, classFileManager, getProvenance, InvalidationProfiler.EMPTY.INSTANCE);
}

public DefaultExternalHooks(Optional<ExternalHooks.Lookup> lookup, Optional<ClassFileManager> classFileManager) {
Expand All @@ -44,23 +54,31 @@ public Optional<ClassFileManager> getExternalClassFileManager() {

@Override public GetProvenance getProvenance() { return getProvenance; }

@Override
public InvalidationProfiler getInvalidationProfiler() { return invalidationProfiler; }

@Override
public ExternalHooks withExternalClassFileManager(ClassFileManager externalClassFileManager) {
Optional<ClassFileManager> external = Optional.of(externalClassFileManager);
Optional<ClassFileManager> mixedManager = classFileManager.isPresent()
? Optional.of(WrappedClassFileManager.of(classFileManager.get(), external))
: external;
return new DefaultExternalHooks(lookup, mixedManager, getProvenance);
return new DefaultExternalHooks(lookup, mixedManager, getProvenance, invalidationProfiler);
}

@Override
public ExternalHooks withExternalLookup(ExternalHooks.Lookup externalLookup) {
Optional<Lookup> externalLookup1 = Optional.of(externalLookup);
return new DefaultExternalHooks(externalLookup1, classFileManager, getProvenance);
return new DefaultExternalHooks(externalLookup1, classFileManager, getProvenance, invalidationProfiler);
}

@Override
public ExternalHooks withGetProvenance(GetProvenance getProvenance) {
return new DefaultExternalHooks(lookup, classFileManager, getProvenance);
return new DefaultExternalHooks(lookup, classFileManager, getProvenance, invalidationProfiler);
}

@Override
public ExternalHooks withInvalidationProfiler(InvalidationProfiler profiler) {
return new DefaultExternalHooks(lookup, classFileManager, getProvenance, profiler);
}
}

0 comments on commit c071d34

Please sign in to comment.