forked from corda/corda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CORDA-2390] - Add whitelists and custom serializers from cordapps to…
… serialization … (corda#4551) * Add whitelists and custom serializers from cordapps to serialization context * Remove changes in TransactionBuilder, add caching * Add whitelists and custom serializers from cordapps to serialization context * Remove changes in TransactionBuilder, add caching * Address comments * Increase node memory for SIMM integration test * Cache only serialization context * Increase integ test timeout * Fix API breakage * Increase max heap size for web server integ test * Move classloading utils from separate module to core.internal * Adjust heap size for more integ tests * Increase time window for IRS demo transactions * Fix determinator * Add parameter in core-deterministic * Stub out class-loading method for DJVM
- Loading branch information
Showing
37 changed files
with
278 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
core-deterministic/testing/src/test/kotlin/net/corda/core/internal/ClassLoadingUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.corda.core.internal | ||
|
||
/** | ||
* Stubbing out non-deterministic method. | ||
*/ | ||
fun <T: Any> loadClassesImplementing(classloader: ClassLoader, clazz: Class<T>): Set<T> { | ||
return emptySet() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
core/src/main/kotlin/net/corda/core/internal/ClassLoadingUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.corda.core.internal | ||
|
||
import io.github.classgraph.ClassGraph | ||
import net.corda.core.CordaInternal | ||
import net.corda.core.DeleteForDJVM | ||
import net.corda.core.StubOutForDJVM | ||
import kotlin.reflect.full.createInstance | ||
|
||
/** | ||
* Creates instances of all the classes in the classpath of the provided classloader, which implement the interface of the provided class. | ||
* @param classloader the classloader, which will be searched for the classes. | ||
* @param clazz the class of the interface, which the classes - to be returned - must implement. | ||
* | ||
* @return instances of the identified classes. | ||
* @throws IllegalArgumentException if the classes found do not have proper constructors. | ||
* | ||
* Note: In order to be instantiated, the associated classes must: | ||
* - be non-abstract | ||
* - either be a Kotlin object or have a constructor with no parameters (or only optional ones) | ||
*/ | ||
@StubOutForDJVM | ||
fun <T: Any> loadClassesImplementing(classloader: ClassLoader, clazz: Class<T>): Set<T> { | ||
return ClassGraph().addClassLoader(classloader) | ||
.enableAllInfo() | ||
.scan() | ||
.getClassesImplementing(clazz.name) | ||
.filterNot { it.isAbstract } | ||
.mapNotNull { classloader.loadClass(it.name).asSubclass(clazz) } | ||
.map { it.kotlin.objectInstance ?: it.kotlin.createInstance() } | ||
.toSet() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.