Fix warnings #124

Merged
merged 4 commits into from Oct 28, 2013

Conversation

Projects
None yet
2 participants
@sharwell
Contributor

sharwell commented Sep 23, 2013

  • Fix improper/sub-optimal generics usage
  • Call static method directly, not through instance
  • Improved specification of compiler arguments in pom.xml

After this change, the project builds without warnings even with -Xlint -Xlint:-serial.

@ndw

This comment has been minimized.

Show comment
Hide comment
@ndw

ndw Sep 24, 2013

Owner

Interesting. A useful refresher on some aspects of generics I've not used a lot. A couple of questions.

  1. In places like BaseURI.java, what motivates the use of <?>. It doesn't seem to have any consequences elsewhere, though perhaps it avoids a compiler warning that I haven't noticed.
  2. In Template.java, and a few other places, what motivated changing Iterator<String> prefixes to Iterator<?> prefixes and adding a (String) cast?
Owner

ndw commented Sep 24, 2013

Interesting. A useful refresher on some aspects of generics I've not used a lot. A couple of questions.

  1. In places like BaseURI.java, what motivates the use of <?>. It doesn't seem to have any consequences elsewhere, though perhaps it avoids a compiler warning that I haven't noticed.
  2. In Template.java, and a few other places, what motivated changing Iterator<String> prefixes to Iterator<?> prefixes and adding a (String) cast?
@sharwell

This comment has been minimized.

Show comment
Hide comment
@sharwell

sharwell Sep 24, 2013

Contributor

I rebased this change on commit 9976a12, and added an additional commit to address warnings that were introduced by 2733096 (a commit which was added after my original work on this branch).

Contributor

sharwell commented Sep 24, 2013

I rebased this change on commit 9976a12, and added an additional commit to address warnings that were introduced by 2733096 (a commit which was added after my original work on this branch).

@sharwell

This comment has been minimized.

Show comment
Hide comment
@sharwell

sharwell Sep 24, 2013

Contributor

To answer your questions:

  1. SequenceIterator is a generic type. In these cases, we don't care what the generic type argument is so using <?> fixes the lint warnings without requiring changing a bunch of the code.
  2. This is the most "interesting" change of the branch IMO, because it seems to be removing generics. It turns out that iteratePrefixes() in the Saxon library returns Iterator (no generic argument specified), which can be implicitly assigned to Iterator<String>, but that introduces an unchecked warning. You can also assign it to Iterator, but that introduces a rawtypes warning. Assigning it to Iterator<?> is safe and does not result in any warnings, but like using a raw Iterator the next() method will require a cast to the target type.
Contributor

sharwell commented Sep 24, 2013

To answer your questions:

  1. SequenceIterator is a generic type. In these cases, we don't care what the generic type argument is so using <?> fixes the lint warnings without requiring changing a bunch of the code.
  2. This is the most "interesting" change of the branch IMO, because it seems to be removing generics. It turns out that iteratePrefixes() in the Saxon library returns Iterator (no generic argument specified), which can be implicitly assigned to Iterator<String>, but that introduces an unchecked warning. You can also assign it to Iterator, but that introduces a rawtypes warning. Assigning it to Iterator<?> is safe and does not result in any warnings, but like using a raw Iterator the next() method will require a cast to the target type.

@sharwell sharwell referenced this pull request Oct 23, 2013

Closed

Extension stubs artifact #122

@ndw ndw merged commit 9976a12 into ndw:saxon94 Oct 28, 2013

ndw added a commit that referenced this pull request Oct 28, 2013

@sharwell sharwell deleted the sharwell:fix-warnings branch Oct 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment