Skip to content

Commit dab4031

Browse files
committed
Address comments of code review
1 parent a77b126 commit dab4031

File tree

8 files changed

+56
-24
lines changed

8 files changed

+56
-24
lines changed

test-app/app/build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
* -PandroidXMaterial=[androidx_material_version]
1919
*/
2020

21+
22+
import groovy.io.FileType
2123
import groovy.json.JsonSlurper
24+
25+
import javax.inject.Inject
2226
import java.nio.file.Files
2327
import java.nio.file.Paths
2428
import java.nio.file.StandardCopyOption
25-
import groovy.io.FileType
2629
import java.security.MessageDigest
27-
import javax.inject.Inject
30+
2831
apply plugin: "com.android.application"
2932

3033
def onlyX86 = project.hasProperty("onlyX86")
@@ -545,7 +548,7 @@ afterEvaluate { project ->
545548
// if there's a project dependency search for its result jar file in the build/intermediates/runtime_library_classes folder
546549
// this is the output folder in gradle 5.1.1, but it can be changed in the future versions of gradle
547550
def jarDir = new File("${it.getBuildDir()}/intermediates/runtime_library_classes/${buildType.toLowerCase()}")
548-
if(jarDir.exists()) {
551+
if (jarDir.exists()) {
549552
jarDir.eachFileRecurse(FileType.FILES) { file ->
550553
if (file.path.endsWith(".jar")) {
551554
processJar(file, jars)
@@ -574,7 +577,7 @@ def processJar(File jar, jars) {
574577
// directory is a randomly generated string)
575578
cleanupAllJars.inputs.files jar
576579

577-
task "${taskName}" (type: WorkerTask) {
580+
task "${taskName}"(type: WorkerTask) {
578581
dependsOn cleanupAllJars
579582
extractAllJars.dependsOn it
580583

@@ -695,7 +698,12 @@ task buildMetadata(type: JavaExec) {
695698

696699
def generatedClasses = new LinkedList<String>()
697700
for (File subDir : classesSubDirs) {
701+
System.out.println("!!!!! VM: subdir path: " + subDir.getAbsolutePath())
702+
System.out.println("!!!!! VM: subdir name: " + subDir.getName())
703+
System.out.println("!!!!! VM: build type: " + selectedBuildType)
704+
698705
if (subDir.getName().equals(selectedBuildType)) {
706+
System.out.println("!!!!! VM: adding")
699707
generatedClasses.add(subDir.getAbsolutePath())
700708
}
701709
}

test-app/app/src/main/assets/app/tests/testsForRuntimeBindingGenerator.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ describe("Tests for runtime binding generator", function () {
4949
expect(isInstanceOf).toEqual(true);
5050
});
5151

52+
it("When_implementing_interface_and_its_implemented_interfaces", function() {
53+
var impl = new com.tns.tests.MyDerivedPublicInterface({
54+
methodOfMyDerivedPublicInterface: function(input) {
55+
return "Le java " + input;
56+
},
57+
methodOfMyPublicInterface: function(input) {
58+
return "Le java " + input;
59+
}
60+
});
61+
62+
var expected = "Le java test derived method";
63+
var actual = impl.methodOfMyPublicInterface("test derived method");
64+
expect(actual).toBe(expected);
65+
});
66+
5267
it("When_generating_a_class_that_implements_interfaces_javascript", function() {
5368

5469
__log("TEST: When_generating_a_class_that_implements_interfaces_javascript");

test-app/runtime/src/main/java/com/tns/DexFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,11 @@ public Class<?> resolveClass(String baseClassName, String name, String className
157157
}
158158

159159
Class<?> result;
160+
DexClassLoader dexClassLoader = new DexClassLoader(jarFilePath, this.odexDir.getAbsolutePath(), null, classLoader);
160161

161162
if (isInterface) {
162-
DexClassLoader dexClassLoader = new DexClassLoader(jarFilePath, this.odexDir.getAbsolutePath(), null, classLoader);
163163
result = dexClassLoader.loadClass(fullClassName);
164164
} else {
165-
DexClassLoader dexClassLoader = new DexClassLoader(jarFilePath, this.odexDir.getAbsolutePath(), null, classLoader);
166165
result = dexClassLoader.loadClass(desiredDexClassName);
167166
}
168167

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.tns.system.classes.loading;
2+
3+
public class LookedUpClassNotFound extends RuntimeException {
4+
5+
private static final long serialVersionUID = 123321L;
6+
7+
public LookedUpClassNotFound(String message) {
8+
super(message);
9+
}
10+
}

test-app/runtime/src/main/java/com/tns/system/classes/loading/impl/ClassStorageServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.tns.system.classes.caching.ClassCache;
44
import com.tns.system.classes.loading.ClassStorageService;
5+
import com.tns.system.classes.loading.LookedUpClassNotFound;
56
import com.tns.system.classloaders.ClassLoadersCollection;
67

78
public class ClassStorageServiceImpl implements ClassStorageService {
@@ -42,7 +43,7 @@ public Class<?> retrieveClass(String lookupKey) {
4243
}
4344
}
4445

45-
throw new RuntimeException("Class \"" + lookupKey + "\" not found.");
46+
throw new LookedUpClassNotFound("Class \"" + lookupKey + "\" not found.");
4647
}
4748

4849
@Override

test-app/runtime/src/main/java/com/tns/system/classloaders/ClassLoadersCollection.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
import java.util.Collection;
44

55
public interface ClassLoadersCollection {
6+
7+
/**
8+
* Adds a class loader to the internal collection of class loaders
9+
*
10+
* @param classLoader class loader to add; should not be null
11+
*/
612
void addClassLoader(ClassLoader classLoader);
13+
14+
/**
15+
* Returns an unmodifiable collection of the stored class loaders
16+
*
17+
* @return unmodifiable collection
18+
*/
719
Collection<ClassLoader> getClassLoadersCollection();
820
}

test-app/runtime/src/test/java/com/tns/system/classes/loading/impl/ClassStorageServiceImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.tns.system.classes.caching.ClassCache;
44
import com.tns.system.classes.loading.ClassStorageService;
5+
import com.tns.system.classes.loading.LookedUpClassNotFound;
56
import com.tns.system.classloaders.ClassLoadersCollection;
67

78
import org.junit.Before;
@@ -95,8 +96,7 @@ public void testRetrieveClassShouldThrowExceptionIfClassIsNotFound() {
9596
try {
9697
classStorageService.retrieveClass(TEST_CLASS_LOOKUP_NAME);
9798
fail();
98-
} catch (RuntimeException e) {
99-
assertEquals("Unexpected exception type", RuntimeException.class.getName(), e.getClass().getName());
99+
} catch (LookedUpClassNotFound e) {
100100
assertEquals("Unexpected exception message", "Class \"" + TEST_CLASS_LOOKUP_NAME + "\" not found.", e.getMessage());
101101
}
102102
}

test-app/runtime/src/test/java/com/tns/system/classloaders/impl/ClassLoadersCollectionImplTest.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,10 @@ public void testAddClassLoaderShouldThrowExceptionIfClassLoaderIsNull() {
2424
}
2525
}
2626

27-
@Test(expected = UnsupportedOperationException.class)
27+
@Test
2828
public void testGetClassLoadersCollectionIsImmutable() {
2929
Collection<ClassLoader> classLoaders = classLoadersCollection.getClassLoadersCollection();
3030

31-
classLoaders.add(null);
32-
fail();
33-
classLoaders.addAll(null);
34-
fail();
35-
classLoaders.clear();
36-
fail();
37-
classLoaders.remove(null);
38-
fail();
39-
classLoaders.removeAll(null);
40-
fail();
41-
classLoaders.retainAll(null);
42-
fail();
43-
classLoaders.iterator().remove();
44-
fail();
31+
assertEquals("Unexpected collection type", "UnmodifiableCollection", classLoaders.getClass().getSimpleName());
4532
}
4633
}

0 commit comments

Comments
 (0)