-
Notifications
You must be signed in to change notification settings - Fork 492
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
Add (diamond) type arguments to lots of files, clean up unused imports #933
Conversation
Raw `List`, `ArrayList`, `Class` and other types were used in many files. I used Eclipse and NetBeans to identify and transform these into fully typed variables/parameters/arguments and diamond-typed definitions and references. In a few places this was not possible; I added a FIXME in one of them (in DataversePage.java).
@bencomp as I mentioned at http://irclog.iq.harvard.edu/dataverse/2014-09-23#i_12869 it would be very helpful if you would provide us with the warning you are trying to correct. Please point me to a line in one of the files and the warning you are seeing either from Netbeans or a command line tool. Thanks! |
In general, this is called the "unchecked assignment" warning, explained at http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#FAQ202. Using raw types causes these warnings, because the compiler cannot know at compile time that casts from items in a e.g. raw IntelliJIDEA finds 170 occurrences of this type of warning in the master branch. In NetBeans you can see the compiler warnings by enabling Raw Types under Standard Javac Warnings on the Hints tab in the Editor options. In the screenshot , NetBeans shows a warning for AdvancedSearchPage.java on line 30:
|
As of
@michbarsinai what do you think about all of this? You're our type safety guy. :)
gives this warning: [WARNING] /Users/pdurbin/NetBeansProjects/dataverse/src/main/java/edu/harvard/iq/dataverse/DataverseFacetServiceBean.java:[20,69] unchecked conversion |
The compiler is correct in a very skewed way. Just add <> so that the 'new' call looks like new LruCache<>() and you'll be fine. I'd say more, but I'm typing this on a smartphone :-( Sent from my iPhone
|
I'm seeing "We can’t automatically merge this pull request" which isn't surprising because 100 files were changed and the code is actively being worked on. This is too many files for us to reason about at once. @bencomp I'm going to close this pull request but yes, we are certainly thinking about the ideas it represents, as you asked at http://irclog.iq.harvard.edu/dataverse/2015-01-14#i_15308 . Thanks! It sounds like you aren't offended, which is great. :) Let's put our energy toward #775 in which we are defining our coding standards in a Google doc for now, where public comments are enabled. |
(This pull request is an improved 'version' of #931.)
Where raw types were used, most calls have been typed with either the full class name or the diamond operator provided by Java 7. In some cases,
Class
references were changed toClass<?>
. I manually removed class casts where the type additions made them obviously redundant. InDataversePage.getContents()
I couldn't add type arguments because theList
used internally contains different types andaddAll()
does not work well with<? extends DvObject>
(hints can be found in Java generics and the addAll method.CommandHelper and ServiceRegistry need another closer look, as my changes may touch upon the purpose or design of these classes.
I let Eclipse remove unused imports, which accounts for a large part of the deletions.
In a few places I corrected a typo or two.