Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android)(8_0_X): resolve template compatibility with Java 9+ #10712

Merged
merged 13 commits into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2867,9 +2867,6 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
let titaniumPrep = 'titanium_prep';
if (process.platform === 'darwin') {
titaniumPrep += '.macos';
if (appc.version.lt(this.jdkInfo.version, '1.7.0')) {
titaniumPrep += '.jdk16';
}
} else if (process.platform === 'win32') {
titaniumPrep += '.win32.exe';
} else if (process.platform === 'linux') {
Expand Down
6 changes: 2 additions & 4 deletions android/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ AndroidModuleBuilder.prototype.initialize = function initialize(next) {
this.androidMkTemplateFile = path.join(this.moduleGenTemplateDir, 'Android.mk.ejs');
this.applicationMkTemplateFile = path.join(this.moduleGenTemplateDir, 'Application.mk.ejs');
this.commonJsSourceTemplateFile = path.join(this.moduleGenTemplateDir, 'CommonJsSourceProvider.java.ejs');
this.assetCryptImplTemplateFile = path.join(this.moduleGenTemplateDir, 'AssetCryptImpl.java.ejs');
this.assetCryptImplTemplateFile = path.join(this.platformPath, 'templates', 'build', 'AssetCryptImpl.java');

this.moduleJarName = this.manifest.name + '.jar';
this.moduleJarFile = path.join(this.distDir, this.moduleJarName);
Expand Down Expand Up @@ -1454,8 +1454,6 @@ AndroidModuleBuilder.prototype.compileJS = function (next) {
});
}

fs.existsSync(this.buildGenAssetJavaFile) && fs.unlinkSync(this.buildGenAssetJavaFile);

// write the encrypted JS bytes to the generated Java file
fs.writeFileSync(
this.buildGenAssetJavaFile,
Expand All @@ -1466,7 +1464,7 @@ AndroidModuleBuilder.prototype.compileJS = function (next) {
);

fs.writeFileSync(
path.join(this.buildGenJavaDir, 'CommonJsSourceProvider.java'),
path.join(this.buildGenJavaDir, this.moduleIdSubDir, 'CommonJsSourceProvider.java'),
ejs.render(fs.readFileSync(this.commonJsSourceTemplateFile).toString(), { moduleid: this.manifest.moduleid })
);

Expand Down
16 changes: 9 additions & 7 deletions android/templates/build/AssetCryptImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.CharBuffer;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.lang.reflect.Method;
Expand All @@ -16,14 +17,14 @@
import org.appcelerator.titanium.TiApplication;
import android.os.Debug;


public class AssetCryptImpl implements KrollAssetHelper.AssetCrypt
{

private static class Range {
private static class Range
{
int offset;
int length;
public Range(int offset, int length) {
public Range(int offset, int length)
{
this.offset = offset;
this.length = length;
}
Expand Down Expand Up @@ -52,7 +53,8 @@ public String readAsset(String path)
}

@Override
public Collection<String> getAssetPaths() {
public Collection<String> getAssetPaths()
{
return assets.keySet();
}

Expand Down Expand Up @@ -81,8 +83,8 @@ private static byte[] filterDataInRange(byte[] data, int offset, int length)
{
try {
Class clazz = Class.forName("org.appcelerator.titanium.TiVerify");
Method method = clazz.getMethod("filterDataInRange", new Class[] {data.getClass(), int.class, int.class});
return (byte[])method.invoke(clazz, new Object[] { data, offset, length });
Method method = clazz.getMethod("filterDataInRange", new Class[] { data.getClass(), int.class, int.class });
return (byte[]) method.invoke(clazz, new Object[] { data, offset, length });
} catch (Exception e) {
Log.e("AssetCryptImpl", "Unable to load asset data.", e);
}
Expand Down
60 changes: 0 additions & 60 deletions android/templates/module/generated/AssetCryptImpl.java.ejs

This file was deleted.

Binary file modified support/android/lib/closure-compiler.jar
Binary file not shown.
Binary file modified support/android/titanium_prep.linux32
100755 → 100644
Binary file not shown.
Binary file modified support/android/titanium_prep.linux64
100755 → 100644
Binary file not shown.
Binary file modified support/android/titanium_prep.macos
Binary file not shown.
Binary file removed support/android/titanium_prep.macos.jdk16
Binary file not shown.
Binary file modified support/android/titanium_prep.win32.exe
Binary file not shown.
Binary file modified support/android/titanium_prep.win64.exe
Binary file not shown.