Skip to content

Commit

Permalink
Prepare release 6.5.1 (#1616)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: saschaarthur <[email protected]>
  • Loading branch information
3 people authored May 26, 2020
1 parent 06980ed commit c40965d
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 76 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
==

Expand Down
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions test-app/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +28,7 @@ public class ClassDirectory implements ClassMapProvider {

private ClassDirectory(String path) {
this.path = path;
this.classMap = new HashMap<String, NativeClassDescriptor>();
this.classMap = new HashMap<>();
}

public Map<String, NativeClassDescriptor> getClassMap() {
Expand All @@ -50,9 +47,9 @@ public static ClassDirectory readDirectory(String path) throws IOException {

private static void readDirectory(ClassDirectory dir, String path)
throws IOException {
List<File> subDirs = new ArrayList<File>();
List<File> 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)) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeMethodDescriptor> methods = new ArrayList<NativeMethodDescriptor>();
ArrayList<NativeMethodDescriptor> methods = new ArrayList<>();
NativeClassDescriptor currentClass = clazz;
while (currentClass != null) {
NativeMethodDescriptor[] currentClassMethods = currentClass.getMethods();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public String getPropertyName() {
}

public Optional<MethodInfo> getGetterMethod() {
return getterMethod == null ? Optional.<MethodInfo>empty() : Optional.of(getterMethod);
return getterMethod == null ? Optional.empty() : Optional.of(getterMethod);
}

public Optional<MethodInfo> getSetterMethod() {
return setterMethod == null ? Optional.<MethodInfo>empty() : Optional.of(setterMethod);
return setterMethod == null ? Optional.empty() : Optional.of(setterMethod);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -61,7 +62,7 @@ private static void writeInt(int value, StreamWriter out) throws Exception {
private static void writeMethodInfo(MethodInfo mi,
HashMap<String, Integer> 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);
Expand Down Expand Up @@ -190,9 +191,9 @@ public void writeClassValue(StreamWriter writer,
public void writeTree(TreeNode root) throws Exception {
short curId = 0;

ArrayDeque<TreeNode> d = new ArrayDeque<TreeNode>();
ArrayDeque<TreeNode> d = new ArrayDeque<>();

HashMap<String, Integer> uniqueStrings = new HashMap<String, Integer>();
HashMap<String, Integer> uniqueStrings = new HashMap<>();

commonInterfacePrefixPosition = writeUniqueName("com/tns/gen/",
uniqueStrings, outStringsStream);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c40965d

Please sign in to comment.