★ wanayoo — archive 1999 https://github.com/NativeScript/android-runtime/pull/1610Nouvelle recherche | Portail wanayoo
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

Cleanup of warnings / possible not checked nullpointers #1610

Merged
merged 1 commit into from May 20, 2020

Conversation

@saschaarthur
Copy link
Contributor

@saschaarthur saschaarthur commented May 11, 2020

Description

Exception handling / code cleanup

Does your commit message include the wording below to reference a specific issue in this repo?

There was plenty of warnings by my IDE (IntelliJ).
Most of the stuff was because of failing null pointer checks and unreachable/unused code / as well not needed function calls.

Logic is 100% the same.

Does your pull request have unit tests?

Everything fixed here should be covered by already existing unit tests

@cla-bot
Copy link

@cla-bot cla-bot bot commented May 11, 2020

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign the CLA at https://www.nativescript.org/cla.
CLA has not been signed by users: @saschaarthur.
After signing the CLA, you can ask me to recheck this PR by posting @cla-bot check as a comment to the PR.

@saschaarthur
Copy link
Contributor Author

@saschaarthur saschaarthur commented May 11, 2020

@cla-bot check

@cla-bot cla-bot bot added the cla: yes label May 11, 2020
@cla-bot
Copy link

@cla-bot cla-bot bot commented May 11, 2020

The cla-bot has been summoned, and re-checked this pull request!

if (!isKotlinClass) {
return new JavaClassDescriptor(javaClass);
}
return new JavaClassDescriptor(javaClass);

This comment has been minimized.

@NathanaelA

NathanaelA May 11, 2020
Member

I believe this is only supposed to occur on a Kotlin class; which is why it is wrapped in the if statement.

This comment has been minimized.

@vmutafov

vmutafov May 11, 2020
Contributor

The if statement seems unnecessary as we return some lines above in the case of Kotlin originating bytecode and the only case we will reach this point is when we're dealing with Java originating bytecode

This comment has been minimized.

@saschaarthur

saschaarthur May 11, 2020 •
Author Contributor

The IDE complained that the if statement is always false.
Which is correct, its never set to true and then reached.

This comment has been minimized.

@NathanaelA

NathanaelA May 11, 2020
Member

You are correct, I totally missed the "return on line 87/82" Duh. :D

@@ -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();

This comment has been minimized.

@NathanaelA

NathanaelA May 11, 2020
Member

These are supposed to be the UNBOXED values. By default .get() returns a Java Integer class; and we want to make sure that we are using the unboxed value later in the app. Please revert that code.

This comment has been minimized.

@vmutafov

vmutafov May 11, 2020
Contributor

It should be autounboxed by the JVM, and this is also a build time step. I believe this change is ok.

if (!isKotlinClass) {
return new JavaClassDescriptor(javaClass);
}
return new JavaClassDescriptor(javaClass);

This comment has been minimized.

@vmutafov

vmutafov May 11, 2020
Contributor

The if statement seems unnecessary as we return some lines above in the case of Kotlin originating bytecode and the only case we will reach this point is when we're dealing with Java originating bytecode

@@ -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();

This comment has been minimized.

@vmutafov

vmutafov May 11, 2020
Contributor

It should be autounboxed by the JVM, and this is also a build time step. I believe this change is ok.

@saschaarthur saschaarthur force-pushed the saschaarthur:fix/warning_cleanup branch from ff0c7ec to c2c7932 May 11, 2020
@saschaarthur
Copy link
Contributor Author

@saschaarthur saschaarthur commented May 11, 2020

readded .intValue() unboxing, to be very clear that we want to have here int not Integer

@vmutafov
Copy link
Contributor

@vmutafov vmutafov commented May 20, 2020

@saschaarthur there is no difference in this case. If the Integer value is null it would crash in both ways. Calling intValue() is not necessary like you first suggested.

@vmutafov vmutafov merged commit fa31074 into NativeScript:master May 20, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
verification/cla-signed
Details
vmutafov added a commit that referenced this pull request May 26, 2020
* 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 <martin.bektchiev@progress.com>
Co-authored-by: saschaarthur <sascha.arthur@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.