Commit Graph

394 Commits

Author SHA1 Message Date
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 12ca05ddb7 Enforce not using raw types more forcefully where possible
These are all modules where no such warnings currently arise.  If any
arise in the future, then, let's treat them as errors so we keep
things clean.
2017-11-28 14:09:42 -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 5bc0e11e90 Ignore invalid Javadoc here, in case we don't have Android's SDK 2017-11-27 11:31:15 -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
Ben Liblit 11828c57f4 Update more parts of the build configuration to use Java 8
Julian Dolby assures me that WALA is now supposed to be using Java 8
everywhere.  This covers nearly all remaining places that I can find
where an earlier Java version was still being used.  (The few
exceptions are places where switching to Java 8 causes test failures.
I'll address those separately, probably by reaching out to the WALA
maintainers for help.)
2017-11-26 18:46:00 -06:00
Ben Liblit ded9e880b1 Update Maven Central configurations to also use Java 8 (#264)
E-mail exchanged with Julian Dolby suggests that this is the right
thing to do, and that it should have been done back when we converted
other parts of the build configuration to Java 8.
2017-11-23 12:55:05 -08:00
Julian Dolby 45da66a95d cleanups and changes for TAMU work 2017-11-22 18:24:39 -05:00
Achim D. Brucker 108dea730b Merge remote-tracking branch 'upstream/master' 2017-11-14 05:31:19 +00:00
Julian Dolby d124256835 remove java 7 support 2017-11-11 21:20:41 -05: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 559c577093 Treat diagnostics about unchecked type operations as errors 2017-08-28 11:55:56 -07: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
Manu Sridharan 14ec60add8 remove unneeded .classpath entry 2017-08-27 15:32:24 -07:00
Julian Dolby b5b67f3d7c issues with mvncentral.xml 2017-08-25 12:00:39 -04:00
Julian Dolby b6af5267f1 java 8 changes
minor fixes, such as making CheckForFrontEndErrors more accessible
minor hacks to make stuff compile with TeaVM
2017-08-25 10:58:00 -04:00
Julian Dolby e599d58cd7 Merge branch 'master' of https://github.com/wala/WALA 2017-08-16 14:50:12 -04:00
Julian Dolby 3371e23de0 java 8 stuff 2017-08-16 14:50:01 -04:00
Ben Liblit b70d69d62f Treat many Eclipse plugin-related problems as errors
These are all problems that Eclipse can detect, but that it detects no
instances of right now.  Treating these as warnings instead of errors
should help prevent us from slipping backward in the future.
2017-08-16 11:36:46 -07:00
Julian Dolby 4a33c527d2 Merge branch 'master' of https://github.com/wala/WALA 2017-08-15 18:01:41 -04:00
Ben Liblit d73b11fd8f Escalate switch-related diagnostics from warnings to errors
We have fixed all of these that Eclipse reports.  Treating them as
errors in the future should help us keep moving in the direction of
cleaner code.
2017-08-15 14:55:34 -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
Julian Dolby a92b881c22 Merge branch 'master' of https://github.com/wala/WALA 2017-08-15 12:39:27 -04:00
Julian Dolby 6431cbeb60 java 8 2017-08-15 12:39:19 -04: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 e7a152341c update dependencies 2017-08-06 20:03:37 -04:00
Julian Dolby 2fbe15fc91 fetch guava 22 2017-08-06 19:30:16 -04: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 15f54f0248 Merge branch 'master' of https://github.com/wala/WALA 2017-08-06 10:30:32 -04:00
Manu Sridharan e8bdf2f8f9 version 1.4.4-SNAPSHOT 2017-08-06 07:25:20 -07:00
Julian Dolby 69929b4985 Merge branch 'master' of https://github.com/wala/WALA 2017-08-06 08:06:02 -04:00
Julian Dolby 34dd8c1f04 merge 2017-08-06 08:05:59 -04:00
Manu Sridharan d901b13425 version 1.4.3 2017-08-05 20:52:32 -07: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
Ben Liblit 678e3e64a6 Fix all Eclipse warnings about unused local variables
Also report unused variables as errors in the future, not just
warnings.  We've fixed all of these as of right now, so let's keep it
clean in the future too.
2017-08-05 13:29:50 -07:00
Julian Dolby 1d144db6d5 Merge branch 'master' of https://github.com/wala/WALA 2017-08-02 12:27:22 -04:00
Achim D. Brucker 409ab78e36 Merge remote-tracking branch 'upstream/master' 2017-08-01 23:50:46 +01:00
Ben Liblit f7dc0a06de Treat unused parameters as errors, not merely warnings
We've fixed or suppressed all such warnings, except in projects
containing test inputs.  Let's make sure no more appear in the future.
2017-07-31 15:29:00 -07:00
Julian Dolby 27e906135f Merge branch 'master' of https://github.com/wala/WALA 2017-07-24 10:08:10 -04:00
Achim D. Brucker 48631092c3 Tuned warning level down. 2017-07-24 08:28:22 +01:00
Achim D. Brucker 7cc2b5c8f5 Merge remote-tracking branch 'upstream/master' 2017-07-24 08:14:25 +01:00
Ben Liblit 10dff7fb1c Disable Eclipse warnings about assignments to parameters
Previously we had 227 such warnings.  That large number suggests that
the WALA developers consider this to be an acceptable coding style.
If that's so, then it's better to hide these warnings rather than keep
them around as a perpetual distraction.
2017-07-18 20:43:36 -07:00
Ben Liblit d3c4200bc3 Disable Eclipse warnings about name shadowing
Previously we had 242 such warnings.  That large number suggests that
the WALA developers consider this to be an acceptable coding style.
If that's so, then it's better to hide these warnings rather than keep
them around as a perpetual distraction.
2017-07-18 20:43:36 -07:00
Julian Dolby 289efc3bb8 Merge branch 'master' of https://github.com/wala/WALA 2017-07-12 08:08:34 -04:00
Ben Liblit 0bbe9970c6 Enable Eclipse Oxygen's new "unlikely argument types" diagnostics
There are two such diagnostics: one for collection methods and one for
equals().  See
<https://www.eclipse.org/eclipse/news/4.7/jdt.php#unlikely-argument-types>
for more information about these two new diagnostics.

For each of these diagnostics, I've set the severity level to
"warning" in projects that have some instances of the suspicious code,
or to "error" in projects that have no instances of the suspicious
code.
2017-07-08 13:22:00 -07:00
Achim D. Brucker 0e89268f4d Merge remote-tracking branch 'upstream/master' 2017-06-29 08:41:57 +01:00
Julian Dolby 7ea9bca169 Merge branch 'master' of https://github.com/wala/WALA 2017-06-26 15:05:29 -04:00
Ben Liblit 3187d09c1f Roll some diagnostics back to ignore instead of warning or error
These should mostly be things that we've already decided earlier that
we explicitly don't want to "fix" because they simply disagree with
the WALA project's coding style.
2017-06-26 11:16:09 -07:00
Ben Liblit fb9042d3a6 Activate more Eclipse diagnostics, and treat many warnings as errors
The additional diagnostics are ones that were previously being
ignored, but which we seem to have been ignoring by default rather
than as a conscious choice.

For diagnostics of which we currently have *zero* instances, treat
these as errors rather than merely warnings.  The intent is to
permanently lock out future regressions of things we've completely
fixed.  In the future, whenever we fix the last instance of a given
warning in a given Eclipse project, we should also promote that
diagnostic to an error to keep things clean into the future.
2017-06-26 11:16:09 -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 9c81cae9be Externalize bundle names and vendors
This fixes 33 Eclipse "The value for attribute '...' is not
externalized.  The value must begin with %" warnings in the "Plug-in
Development" category.
2017-06-07 17:42:11 +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
Ben Liblit e1d2fa9850 Suppress Eclipse warnings about potentially-static methods
The "potentially" qualifier is here because these methods are visible
outside the WALA source tree.  These methods may seem OK to be static
based on the code we have here, but we have no way of knowing whether
third-party code expected to be able to subclass and override.  I'm
going to play it safe and assume that we want to allow that.

Note that we are still allowing Eclipse warnings about methods that
can *definitely* be declared static; a different configuration option
controls these.  For private methods, final methods, and methods in
final classes, if the code seems static-safe based on what we have
here, then that's good enough: we don't need to worry about
third-party overrides.
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
Julian Dolby f54346b36c Merge branch 'master' of https://github.com/wala/WALA 2017-05-08 10:48:05 -04:00
Ben Liblit 4cef26162c Add @Override annotations wherever possible (#178)
* Fix warnings about unset javacProjectSettings build entries

Specifically, these are all warnings of the form "The
'javacProjectSettings' build entry should be set when there are project
specific compiler settings".

* Add @Override annotations to all methods that do override

This fixes 287 Eclipse code style warnings.

* Cannot add @Override annotations here, so suppress warnings instead

We should be able to add these @Override annotations in the future,
one Eclipse Mars and earlier are no longer supported.  For now,
though, they have to go away in order to be compatible with older
Eclipse releases.
2017-05-08 07:39:49 -07:00
Julian Dolby 8747917c7b Merge branch 'master' of https://github.com/wala/WALA 2017-05-08 08:45:11 -04:00
Ben Liblit ae7b365493 Suppress a few Eclipse code style warnings that are not WALA style (#177)
* Fix warnings about unset javacProjectSettings build entries

Specifically, these are all warnings of the form "The
'javacProjectSettings' build entry should be set when there are project
specific compiler settings".

* Turn off Eclipse warnings about undocumented empty blocks

The presence of 65 such warnings in two packages suggests that the de
facto WALA coding style does not mandate documenting empty blocks.
Better to avoid printing warnings that will be routinely ignored, so
that other important warnings are more likely to be noticed.

* Turn off Eclipse warnings about synthetic accessor methods

Synthetic accessor methods allow access to otherwise inaccessible
members of enclosing types.  The presence of 246 such warnings in
three packages suggests that the de facto WALA coding style does not
consider synthetic accessor methods to be problematic.  Better to
avoid printing warnings that will be routinely ignored, so that other
important warnings are more likely to be noticed.
2017-05-07 22:57:24 -07:00
Julian Dolby fe636f4b97 Merge branch 'master' of https://github.com/wala/WALA 2017-04-24 16:28:34 -04:00
Manu Sridharan c9022b0743 update version to 1.4.3-SNAPSHOT 2017-04-19 09:19:09 -07:00
Manu Sridharan 44e433085e tag 1.4.2 release 2017-04-19 09:17:13 -07:00
Julian Dolby af83d11a4e Merge branch 'master' of https://github.com/wala/WALA 2017-04-14 10:13:04 -04:00
Manu Sridharan d7878b2bbd Merge pull request #163 from liblit/warning-fixes-plug-in-development
Disable Eclipse warnings about missing version constraints
2017-04-06 16:19:59 -07:00
Julian Dolby 11585f3d34 Merge branch 'master' of https://github.com/wala/WALA 2017-03-30 21:58:56 -04:00
Ben Liblit d35e8d0fa2 Disable Eclipse warnings about missing version constraints
Specifically, we're turning off Eclipse warnings about missing version
constraints on required bundles ("Require-Bundle"), exported
packages ("Export-Package"), and imported packages ("Import-Package").
We're not turning these off absolutely everywhere, though: only in
packages where one or more such warnings were actually being reported.
So if a given package was already providing all version constraints
for, say, package imports, then we've kept that warning on in that
package.

Honestly I don't entirely understand the practical implications of
these warnings.  However, there were 355 of them across many WALA
subprojects.  I take this as evidence that the WALA developers do not
consider these version constraints to be important.  Therefore, we may
as well stop warning about something we have no intention of fixing.

That being said, if we *do* want to fix some or all of these, I
welcome any advice on what those fixes should look like.  I am rather
ignorant about all things OSGi.
2017-03-28 20:37:41 -05:00
Ben Liblit b197c231e0 Fix Eclipse warnings about declared but not-thrown exceptions 2017-03-28 18:20:36 -05:00
Ben Liblit 2f7b52b01c Fix Eclipse warnings about unused imports 2017-03-28 18:20:33 -05:00
Julian Dolby 91ed8f6752 Merge branch 'master' of https://github.com/wala/WALA 2017-03-28 16:34:38 -04:00
Julian Dolby 59337d0d05 Merge branch 'master' of https://github.com/wala/WALA 2017-03-28 16:34:29 -04:00
Ben Liblit 65be11f222 Merge branch 'master' into warning-fixes-unnecessary-code-controversial 2017-03-25 22:12:03 -05:00
Ben Liblit b4e5d078dd Retain some unused methods
Manu requests that we keep these around even though they are currently
unused.  So we'll retain them, but also annotate them to suppress the
warning.
2017-03-25 17:11:34 -05:00
Ben Liblit 64dfd2d908 Turn off Eclipse warnings about unnecessary `else` clauses
If the true block of an `if` statement is guaranteed to exit early,
such as by a `return` or `throw`, then any code appearing in a
corresponding `else` clause could just as well have appeared after the
`if` statement entirely.  Eclipse can warn about this.

However, Manu prefers to let such code stay in the `else` clauses.
OK, sure: this is more a matter of personal taste than something truly
problematic.  Per Manu's request, then, we're turning off that Eclipse
warning in the subprojects in which it currently arises.
2017-03-25 16:37:09 -05:00
Ben Liblit 83a9201613 Revert "Fix 106 Eclipse warnings about unnecessary else clauses"
This reverts commit 04dafcf7f7.
2017-03-25 16:29:26 -05:00
Manu Sridharan ab7e638c29 version 1.4.2-SNAPSHOT 2017-03-25 13:54:21 -07:00
Manu Sridharan 2d0518963d Tag release 1.4.1 2017-03-25 13:24:39 -07:00
Manu Sridharan c1b2151e08 make Maven Central files for wala.dalvik and wala.scandroid (#158) 2017-03-25 13:20:34 -07:00
Manu Sridharan b82e808b32 Merge pull request #156 from liblit/warning-fixes-unnecessary-code-uncontroversial
Fix 265 Eclipse warnings about unnecessary code
2017-03-23 17:48:10 -07:00
Ben Liblit 1bb3d827c4 Turn off Eclipse warnings about unused caught-exception parameters
Manu requested that we use this approach instead of adding
`@SuppressWarnings("unused")` at each affected catch block.  That
seems reasonable to me, given the large number of such warnings and
the lack of likely harm from ignoring such caught exceptions.
2017-03-23 16:39:58 -05:00
Ben Liblit 16492c7b78 Revert "Suppress 157 Eclipse warnings about unused exception parameters"
This reverts commit fe9f7a793a.
2017-03-23 16:32:00 -05:00
Manu Sridharan 9dafd5050f Merge pull request #155 from liblit/warning-fixes-javadoc-true-fixes
Fix 161 Eclipse Javadoc warnings
2017-03-23 13:30:51 -07:00