Commit Graph

253 Commits

Author SHA1 Message Date
Achim D. Brucker 3d5dec0b0c Manual merge. 2018-10-21 16:31:25 +01:00
Julian Dolby b2503628a4 1) a bit more source mappimg information
2) fixes to how Contexts are combined
2018-10-13 08:42:08 -04:00
Erik Derr 018e9d20eb Fixes Exception in AndroidAnalysisScope (#361)
Fixes inconsistent behavior of the exclusions argument.
Depending on the androidLib argument, setting exclusions to null
is either fine or raises and exception.

This patch makes exclusions truely optional for any case
when null is passed.
2018-10-02 22:29:44 -07:00
Erik Derr ee13713c4d Impl of IMethod.is(Wala)Synthetic and IClass.isSynthetic (#359)
* Impl of IMethod isSynthetic and isWalaSynthetic

So far IMethod.isSynthetic referred to WALA-generated helper functions
and there was no equivalent to check whether an IMethod is synthetic in
terms of compiler-generated.

To make naming consistent this patch first renames the isSynthetic to
isWalaSynthetic to clearly indicate that a given IMethod was generated
by WALA. Then, we re-introduce isSynthetic that from now on checks
whether an IMethod is synthetic/compiler-generated (referring to the
synthetic flag in bytecode)

* Implementation of IClass.isSynthetic

Complementary to IMethod.isSynthetic, this method checks whether
an IClass is compiler-generated.

* updated JavaDoc
2018-10-02 22:28:21 -07:00
Erik Derr 751444a656 Fixes IllegalStateException (#358)
* Fixes IllegalStateException

Reverts refactored code with try-with-resource back to potentially
leaking implementation. The refactored code threw an exception since
JarFileModule does not implement the AutoClosable interface. Further,
removed the printStackTrace() call, as this is not an exceptional case
but intended control-flow in case DexFileModule creation fails.

* Downgrade JarFile leak diagnostic from warning to error

This is consistent with how we are treating potential JarFile leaks in
other WALA components.  WALA issue #236 already notes that these
should be cleaned up eventually, although doing so will not be easy.
2018-09-30 12:19:14 -07:00
Sifis Lagouvardos 2ab002df3e Added new DexFileModule constructor to support specific dex files inside apks. 2018-09-21 19:08:06 -07:00
Julian Dolby e85f01b2b3 fix for Dalvik instruction generation 2018-09-11 13:36:29 -04:00
Ben Liblit b14804bfdc Don't put fixed-name, writable files into "java.io.tmpdir"
If multiple tests both write to "/tmp/cg.txt" (for example), then
these tests cannot safely run concurrently.  That never used to be a
problem with Maven, since our Maven tests were all strictly sequential
anyway.  But parallelized testing using Gradle requires that we do
better.  Fortunately, Java has perfectly reasonable APIs for
generating uniquely-named temporary files and directories.
2018-04-18 11:29:29 -05:00
Ben Liblit 61d8ee1b02 Fix various warnings produced by "./gradlew javadoc"
Three stubborn warnings remain, but this is progress!
2018-04-18 11:29:27 -05:00
Ben Liblit 99c2493e37 Revert "Build WALA using Gradle instead of Maven" (#298) 2018-04-18 12:15:56 -04:00
Ben Liblit 7886fa13dc Don't put fixed-name, writable files into "java.io.tmpdir"
If multiple tests both write to "/tmp/cg.txt" (for example), then
these tests cannot safely run concurrently.  That never used to be a
problem with Maven, since our Maven tests were all strictly sequential
anyway.  But parallelized testing using Gradle requires that we do
better.  Fortunately, Java has perfectly reasonable APIs for
generating uniquely-named temporary files and directories.
2018-04-17 15:02:36 -05:00
Ben Liblit 62d7980ea3 Fix various warnings produced by "./gradlew javadoc"
Three stubborn warnings remain, but this is progress!
2018-04-17 15:02:35 -05:00
Achim D. Brucker f6c663c238 Merge remote-tracking branch 'upstream/master' 2018-04-05 23:19:36 +01:00
Julian Dolby 6c1d0d9cb6 more work for reuse
make synthetic code better support non-Java languages
2018-02-14 09:00:07 -05:00
Julian Dolby c8cdaf8616 further refactoring to enable more reuse
eliminate all non-jva 8 compilation
2018-02-05 15:18:37 -08:00
Ben Liblit 0a770ce7ab "@todo" is not a valid Javadoc tag 2017-12-19 16:53:56 -06:00
Ben Liblit f60c164ec1 Escape "<" and ">" in Javadoc when not used as HTML tag syntax 2017-12-19 16:53:52 -06:00
Ben Liblit 0286c2b048 Use Iterator2Iterable helper to convert more loops to for-each 2017-12-04 14:04:39 -08:00
Ben Liblit 9c83e87cc1 Merge branch 'master' into modernization-java-8-lambdas-and-method-references 2017-11-29 10:51:33 -06:00
Ben Liblit ebfd885d22 Use modern for-each loops where possible
Java sources used as test data have been excluded from this mass
clean-up.
2017-11-28 14:44:53 -06:00
Ben Liblit 8ef6ad5069 Add proper type parameters to nearly all uses of Iterator
Java sources used as test data have been excluded.
2017-11-28 14:09:30 -06:00
Ben Liblit 5fa3643652 Don't suppress javadoc warnings; these are disabled entirely anyway 2017-11-27 11:31:15 -06:00
Ben Liblit 74e0640771 Replace simple lambdas with method references wherever possible 2017-11-27 11:31:15 -06:00
Ben Liblit 790d37781b Convert many single-method anonymous classes to lambdas
Eclipse's automated code clean-up tool did most of the heavy lifting
here: it specifically has a clean-up option for converting functional
interfaces to lambdas.  I merely had to revert the automated changes
for a single enumeration class for which it produced invalid results,
and for a few test inputs that apparently aren't set up to be compiled
with Java 8.
2017-11-27 11:31:15 -06:00
Achim D. Brucker 5d28f92798 Fixed compilation error with Java 8. 2017-09-11 14:35:58 +01:00
Achim D. Brucker 9716d50146 Merged with remote-tracking branch 'upstream/master'. 2017-09-10 23:20:40 +01:00
Ben Liblit f8e3172653 Be explicit about the type parameter in generic static method calls
In modern Java, we would not need to do this.  Java 1.8 can infer the
generic type, which would allow us to write simply
"Collections.emptySet()" instead of
"Collections.<TypeReference>"emptySet()".  Unfortunately, Android is
behind the times, so this specific project targets Java 1.5.  That
older Java definition does not do the inference we would want here, so
we have to be explicit instead.
2017-08-28 11:55:56 -07:00
Ben Liblit 1603ec314f Use Collections.emptySet() instead of Collections.EMPTY_SET
The former returns Set<T> for any T, whereas the latter merely returns
a raw Set.  Using the former instead of the latter fixes four Eclipse
warnings about using raw generics.
2017-08-28 11:55:56 -07:00
Ben Liblit ab791f8c41 Throw a loud exception if switch encounters unexpected enum value
Previously each of these `switch` statements would implicitly do
nothing if an unanticipated `enum` value came along.  My impression is
that each of these `switch` statements is supposed to be exhaustive,
such that an unexpected (unhandled) value should never appear.  If one
does, we should recognize it and complain loudly.

Of course, sometimes the right behavior for previously-unhandled
values is to do nothing.  It may not always be clear whether an
exception or doing nothing is the right choice.  For this commit,
WALA's regression tests still pass even with the possibility of
throwing an exception for unexpected values.  If we assume that the
test suite is thorough, that tells me that throwing an exception is
the right policy for each `switch` statement that I'm changing here.
2017-08-15 14:55:34 -07:00
Ben Liblit 61e9641094 Semantics-preserving control-flow tweaks to fix switch warnings
Eclipse was warning that these `switch` statements had no `default`
cases.  Each did have some default behavior, but implemented outside
the `switch`.  By moving the default behavior into a `default` case
within the `switch`, we eliminate a static warning with no change
whatsoever to the run-time behavior.
2017-08-15 14:55:34 -07:00
Ben Liblit cb6d3b282a Fix Eclipse warnings about redundant null checks and assignments
Most of these are harmless, and are best fixed simply by removing the
redundant check or assignment.  The one in FlowType.compareBlocks,
however, revealed a real problem.  This code checks for nullness of
`a` *after* having called a method on `a`.  Assuming that `a` can
indeed be `null` here, the check must come first to avoid a
`NullPointerException`.

In several places, I saw code of this form:

   if (thing == null)
     assert thing != null : ... ;

I honestly don't understand the purpose of that `if` statement.  Why
not just have the `assert` statement there directly?  I removed the
seemingly irrelevant `if` statements in these cases, but if this is
some intentional pattern, please explain it to me.

In a few places where nullness is statically known but non-obvious,
add assert statements to point out what's going on to help future
developers.

Upgrade future such warnings to errors to keep us moving in a cleaner
direction.
2017-08-15 09:11:29 -07:00
Julian Dolby 7e8e499f04 get actual art version 2017-08-09 17:33:41 -04:00
Julian Dolby ecdb599674 support for deodexing methods read from Dalvik, using support in dexlib2 2017-08-08 06:34:48 -04:00
Achim D. Brucker 29185f272c Merge with upstream. 2017-08-07 12:07:37 +01:00
Julian Dolby cc8831ebcf misc fixes, and optional new translation for for..in; ultimately, this new translation is better, but for now it breaks some correlation-tracking tests, so it is available only as an option. 2017-08-06 18:36:33 -04:00
Julian Dolby b9b498bd17 Merge branch 'master' of https://github.com/wala/WALA 2017-08-05 21:10:28 -04:00
Julian Dolby eaba8d59b7 Merge branch 'master' of https://github.com/wala/WALA 2017-08-05 21:09:34 -04:00
Ben Liblit d6ce679a72 Add static private serialVersionUID fields to Serializable classes
We already have plenty of examples of Serializable classes with this
field, and the vast majority of those fields have generated IDs rather
than "1L".  From this I infer that using proper serialVersionUID
fields is considered appropriate WALA coding style.
2017-08-05 13:30:35 -07:00
Achim D. Brucker e448cf5634 Merge remote-tracking branch 'upstream/master' 2017-06-23 22:22:36 +01:00
Julian Dolby 163e10f5e4 Merge branch 'warning-fixes-plug-in-development-misc' of https://github.com/liblit/WALA 2017-06-22 09:27:47 +02:00
Ben Liblit 8cc4daf6a0 Access static fields directly via the classes that declare them
Previously some of these were accessing such fields through a subclass
of the declaring class.  That creates an unnecessary extra inter-class
dependency lower in the type hierarchy than necessary.

Also, suppress this warning in an automated test input where the
indirect static accesses are explicitly intentional.
2017-06-07 08:29:23 -07:00
Ben Liblit 237b49a425 Declare two public methods of a final class static
These methods access only static members.  They are methods of a final
class, which means no subclass can ever override these methods and use
dynamic dispatch to choose the implementation at run time.  So
declaring these methods static is (statically) safe.
2017-06-07 08:29:23 -07:00
Ben Liblit 72c754e874 Declare private methods static wherever possible
If a method is private, there's no risk that a subclass elsewhere
might be overriding it and depending on dynamic dispatch to choose the
right implementation.  So all of these private methods can safely be
declared static without risk of regression in either WALA code or
unseen third-party code.
2017-06-07 08:29:23 -07:00
Achim D. Brucker 52e8c0ecea Merge remote-tracking branch 'upstream/master' 2017-05-27 10:11:10 +01:00
Julian Dolby fc7c7ec5d1 merge 2017-05-26 19:01:59 -04:00
Ben Liblit dee2412ab5 Remove several unused locals and clean up surrounding code
In all of these cases, the code used to initialize the unused local
seems nontrivial to me.  I think this can all be removed without
erasing any needed side effects, but the code might still become
useful to someone in the future.  So I'm not really removing the code
entirely, but merely commenting it out.
2017-05-26 14:25:03 -07:00
Ben Liblit 97bf43c0b9 Fix Eclipse warnings about unused method parameters 2017-05-26 14:25:03 -07:00
Julian Dolby d4607979ed Merge branch 'master' of https://github.com/wala/WALA 2017-05-26 15:13:28 -04:00
Achim D. Brucker bc4bc846ac Merge remote-tracking branch 'upstream/master' 2017-05-16 10:56:33 +01:00
Ben Liblit 0ffd2bcee4 Add @Override annotations to all methods that do override (#180)
This fixes 49 Eclipse code style warnings.  I'm not sure why these
were overlooked in my previous sweep of missing-@Override warnings.
Ah well; got 'em this time around.
2017-05-15 07:15:00 -07:00