From c40965ddf477e26365d0eb52915b2eb985893530 Mon Sep 17 00:00:00 2001 From: Vladimir Mutafov Date: Tue, 26 May 2020 14:31:00 +0300 Subject: [PATCH] Prepare release 6.5.1 (#1616) * chore:Update CHANGELOG for v6.5.0 * Make buildMetadata aware of whitelist/blacklist files (#1590) * - warning cleanups (#1610) * Bump to 6.5.1 * Update CHANGELOG.md for 6.5.1 * Hardcode first emulator * Use wait-for-device Co-authored-by: Martin Bektchiev Co-authored-by: saschaarthur --- CHANGELOG.md | 14 +++ build.sh | 8 +- package.json | 2 +- test-app/app/build.gradle | 3 + .../src/src/com/telerik/metadata/Builder.java | 6 +- .../com/telerik/metadata/ClassDirectory.java | 17 ++-- .../src/com/telerik/metadata/ClassUtil.java | 5 +- .../src/com/telerik/metadata/Generator.java | 6 +- .../src/com/telerik/metadata/TreeNode.java | 86 ++++++++++--------- .../src/src/com/telerik/metadata/Writer.java | 17 ++-- 10 files changed, 88 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0535913a2..a7471d306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +6.5.1 +== + +## Bug Fixes + +- [Cleanup of warnings / possible not checked nullpointers (#1610)](https://github.com/NativeScript/android-runtime/pull/1610) + +- [[metadata] not rebuilding on json api usage change (#1589)](https://github.com/NativeScript/android-runtime/issues/1589) + +6.5.0 +== + +### No changes + 6.4.1 == diff --git a/build.sh b/build.sh index a152bcbd1..4e6320579 100755 --- a/build.sh +++ b/build.sh @@ -55,10 +55,10 @@ for emulator in $listOfEmulators; do find ~/.android/avd/${emulator}.avd -type f -name 'config.ini' -exec cat {} + echo "Run Android Runtime unit tests for $emulator" - $ANDROID_HOME/platform-tools/adb devices - $ANDROID_HOME/platform-tools/adb -e logcat -c - $ANDROID_HOME/platform-tools/adb -e logcat > consoleLog.txt& - $ANDROID_HOME/platform-tools/adb -e logcat > consoleLog$emulator.txt& + $ANDROID_HOME/platform-tools/adb wait-for-device + $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat -c + $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog.txt& + $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog$emulator.txt& if [ "$1" != 'unit_tests_only' ]; then ./gradlew runtests diff --git a/package.json b/package.json index 445c413c5..6ee439779 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tns-android", "description": "NativeScript Runtime for Android", - "version": "6.5.0", + "version": "6.5.1", "repository": { "type": "git", "url": "https://github.com/NativeScript/android-runtime.git" diff --git a/test-app/app/build.gradle b/test-app/app/build.gradle index f6531ebb2..67fe1e76d 100644 --- a/test-app/app/build.gradle +++ b/test-app/app/build.gradle @@ -767,6 +767,9 @@ task buildMetadata(type: BuildToolTask) { description "builds metadata with provided jar dependencies" inputs.files("$MDG_JAVA_DEPENDENCIES") + + // make MDG aware of whitelist.mdg and blacklist.mdg files + inputs.files(project.fileTree(dir: "$rootDir", include: "**/*.mdg")) def classesDir = "$buildDir/intermediates/javac" inputs.dir(classesDir) diff --git a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Builder.java b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Builder.java index 67437ca53..9ec224f3f 100644 --- a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Builder.java +++ b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Builder.java @@ -438,6 +438,8 @@ private static TreeNode getOrCreateNode(TreeNode root, NativeClassDescriptor cla if (ClassUtil.isPrimitive(clazz)) { TreeNode tmp = TreeNode.getPrimitive(clazz); + if(tmp == null) + throw new UnsupportedOperationException("tmp == null" + clazz.getClassName()); child.nodeType = tmp.nodeType; } else { child.nodeType = clazz.isInterface() ? TreeNode.Interface @@ -449,7 +451,7 @@ private static TreeNode getOrCreateNode(TreeNode root, NativeClassDescriptor cla } node = child; if (node.baseClassNode == null) { - NativeClassDescriptor baseClass = null; + NativeClassDescriptor baseClass; if (predefinedSuperClassname != null) { SecuredNativeClassDescriptor securedNativeClassDescriptor = SecuredClassRepository.INSTANCE.findNearestAllowedClass(predefinedSuperClassname); baseClass = securedNativeClassDescriptor.isUsageAllowed() ? securedNativeClassDescriptor.getNativeDescriptor() : null; @@ -503,6 +505,8 @@ private static TreeNode createArrayNode(TreeNode root, String className) child = currentNode.createChild(name); if (ClassUtil.isPrimitive(name)) { TreeNode node = TreeNode.getPrimitive(name); + if(node == null) + throw new UnsupportedOperationException("node == null: " + name); child.nodeType = node.nodeType; child.arrayElement = node; } else { diff --git a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassDirectory.java b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassDirectory.java index 8792399b4..35c57fe86 100644 --- a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassDirectory.java +++ b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassDirectory.java @@ -16,10 +16,7 @@ import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class ClassDirectory implements ClassMapProvider { private final String path; @@ -31,7 +28,7 @@ public class ClassDirectory implements ClassMapProvider { private ClassDirectory(String path) { this.path = path; - this.classMap = new HashMap(); + this.classMap = new HashMap<>(); } public Map getClassMap() { @@ -50,9 +47,9 @@ public static ClassDirectory readDirectory(String path) throws IOException { private static void readDirectory(ClassDirectory dir, String path) throws IOException { - List subDirs = new ArrayList(); + List subDirs = new ArrayList<>(); File currentDir = new File(path); - for (File file : currentDir.listFiles()) { + for (File file : Objects.requireNonNull(currentDir.listFiles())) { if (file.isFile()) { String name = file.getName(); if (name.endsWith(CLASS_EXT)) { @@ -73,7 +70,6 @@ private static NativeClassDescriptor getClassDescriptor(String name, File file) if (name.endsWith(CLASS_EXT)) { ClassParser cp = new ClassParser(file.getAbsolutePath()); JavaClass javaClass = cp.parse(); - boolean isKotlinClass = false; AnnotationEntry[] annotationEntries = javaClass.getAnnotationEntries(); if (annotationEntries != null) { @@ -82,16 +78,13 @@ private static NativeClassDescriptor getClassDescriptor(String name, File file) if ("Lkotlin/Metadata;".equals(annotationType)) { MetadataAnnotation kotlinClassMetadataAnnotation = new BytecodeMetadataAnnotation(annotationEntry); NativeClassDescriptor kotlinClassDescriptor = new KotlinClassDescriptor(javaClass, kotlinClassMetadataAnnotation); - isKotlinClass = true; analyticsCollector.markHasKotlinRuntimeClassesIfNotMarkedAlready(); return kotlinClassDescriptor; } } } - if (!isKotlinClass) { - return new JavaClassDescriptor(javaClass); - } + return new JavaClassDescriptor(javaClass); } return clazz; diff --git a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassUtil.java b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassUtil.java index 0fb3c7d97..d3feef75f 100644 --- a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassUtil.java +++ b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/ClassUtil.java @@ -61,12 +61,11 @@ public static String getSimpleName(NativeClassDescriptor clazz) { if (idx < 0) { idx = className.lastIndexOf("."); } - String simpleName = className.substring(idx + 1); - return simpleName; + return className.substring(idx + 1); } static NativeMethodDescriptor[] getAllMethods(NativeClassDescriptor clazz) { - ArrayList methods = new ArrayList(); + ArrayList methods = new ArrayList<>(); NativeClassDescriptor currentClass = clazz; while (currentClass != null) { NativeMethodDescriptor[] currentClassMethods = currentClass.getMethods(); diff --git a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Generator.java b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Generator.java index 6c1ff30e1..18ef19a75 100644 --- a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Generator.java +++ b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Generator.java @@ -24,7 +24,7 @@ public class Generator { private static final String MDG_BLACKLIST = "blacklist.mdg"; /** - * @param args + * @param args arguments */ public static void main(String[] args) { enableFlaggedFeatures(args); @@ -38,12 +38,12 @@ public static void main(String[] args) { try { metadataOutputDir = getFileRows(MDG_OUTPUT_DIR).get(0); } catch (Exception e) { - throw new InvalidParameterException(String.format("You need to pass a file containing a single line: the output dir for the metadata generator1\n", e.getMessage())); + throw new InvalidParameterException(String.format("You need to pass a file containing a single line: the output dir for the metadata generator %s\n", e.getMessage())); } try { params = getFileRows(MDG_JAVA_DEPENDENCIES); } catch (Exception e) { - throw new InvalidParameterException(String.format("You need to pass a file containing a list of jar/class paths, so metadata can be generated for them!\n", e.getMessage())); + throw new InvalidParameterException(String.format("You need to pass a file containing a list of jar/class paths, so metadata can be generated for them! %s\n", e.getMessage())); } TreeNode root = Builder.build(params); diff --git a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/TreeNode.java b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/TreeNode.java index 556e40968..1438e5a4b 100644 --- a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/TreeNode.java +++ b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/TreeNode.java @@ -71,11 +71,11 @@ public String getPropertyName() { } public Optional getGetterMethod() { - return getterMethod == null ? Optional.empty() : Optional.of(getterMethod); + return getterMethod == null ? Optional.empty() : Optional.of(getterMethod); } public Optional getSetterMethod() { - return setterMethod == null ? Optional.empty() : Optional.of(setterMethod); + return setterMethod == null ? Optional.empty() : Optional.of(setterMethod); } } @@ -144,51 +144,53 @@ public static TreeNode getPrimitive(NativeClassDescriptor clazz) throws Exceptio String name = clazz.getClassName(); - if (name.equals("byte")) { - return TreeNode.BYTE; - } else if (name.equals("short")) { - return TreeNode.SHORT; - } else if (name.equals("int")) { - return TreeNode.INTEGER; - } else if (name.equals("long")) { - return TreeNode.LONG; - } else if (name.equals("float")) { - return TreeNode.FLOAT; - } else if (name.equals("double")) { - return TreeNode.DOUBLE; - } else if (name.equals("boolean")) { - return TreeNode.BOOLEAN; - } else if (name.equals("char")) { - return TreeNode.CHAR; - } else if (name.equals("void")) { - return null; - } else { - throw new Exception("unknown type=" + name); + switch (name) { + case "byte": + return TreeNode.BYTE; + case "short": + return TreeNode.SHORT; + case "int": + return TreeNode.INTEGER; + case "long": + return TreeNode.LONG; + case "float": + return TreeNode.FLOAT; + case "double": + return TreeNode.DOUBLE; + case "boolean": + return TreeNode.BOOLEAN; + case "char": + return TreeNode.CHAR; + case "void": + return null; + default: + throw new Exception("unknown type=" + name); } } public static TreeNode getPrimitive(String name) throws IllegalArgumentException { - if (name.equals("B")) { - return TreeNode.BYTE; - } else if (name.equals("S")) { - return TreeNode.SHORT; - } else if (name.equals("I")) { - return TreeNode.INTEGER; - } else if (name.equals("J")) { - return TreeNode.LONG; - } else if (name.equals("F")) { - return TreeNode.FLOAT; - } else if (name.equals("D")) { - return TreeNode.DOUBLE; - } else if (name.equals("Z")) { - return TreeNode.BOOLEAN; - } else if (name.equals("C")) { - return TreeNode.CHAR; - } else if (name.equals("V")) { - return null; - } else { - throw new IllegalArgumentException("unknown type=" + name); + switch (name) { + case "B": + return TreeNode.BYTE; + case "S": + return TreeNode.SHORT; + case "I": + return TreeNode.INTEGER; + case "J": + return TreeNode.LONG; + case "F": + return TreeNode.FLOAT; + case "D": + return TreeNode.DOUBLE; + case "Z": + return TreeNode.BOOLEAN; + case "C": + return TreeNode.CHAR; + case "V": + return null; + default: + throw new IllegalArgumentException("unknown type=" + name); } } diff --git a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Writer.java b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Writer.java index fc809640d..7fcda6ae7 100644 --- a/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Writer.java +++ b/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Writer.java @@ -6,6 +6,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; +import java.nio.charset.StandardCharsets; import java.util.ArrayDeque; import java.util.HashMap; import java.util.List; @@ -42,7 +43,7 @@ private static int writeUniqueName(String name, writeUniqueName_lenBuff[1] = (byte) ((len >> 8) & 0xFF); outStringsStream.write(writeUniqueName_lenBuff); - outStringsStream.write(name.getBytes("UTF-8")); + outStringsStream.write(name.getBytes(StandardCharsets.UTF_8)); uniqueStrings.put(name, position); @@ -61,7 +62,7 @@ private static void writeInt(int value, StreamWriter out) throws Exception { private static void writeMethodInfo(MethodInfo mi, HashMap uniqueStrings, StreamWriter outValueStream) throws Exception { - int pos = uniqueStrings.get(mi.name).intValue(); + int pos = uniqueStrings.get(mi.name); writeInt(pos, outValueStream); byte isResolved = (byte) (mi.isResolved ? 1 : 0); @@ -190,9 +191,9 @@ public void writeClassValue(StreamWriter writer, public void writeTree(TreeNode root) throws Exception { short curId = 0; - ArrayDeque d = new ArrayDeque(); + ArrayDeque d = new ArrayDeque<>(); - HashMap uniqueStrings = new HashMap(); + HashMap uniqueStrings = new HashMap<>(); commonInterfacePrefixPosition = writeUniqueName("com/tns/gen/", uniqueStrings, outStringsStream); @@ -275,9 +276,7 @@ public void writeTree(TreeNode root) throws Exception { } } - for (TreeNode child : n.children) { - d.add(child); - } + d.addAll(n.children); } outStringsStream.flush(); @@ -307,9 +306,7 @@ public void writeTree(TreeNode root) throws Exception { throw new Exception("should not happen"); } - for (TreeNode child : n.children) { - d.add(child); - } + d.addAll(n.children); } outValueStream.flush();