You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Rick Hillegas (JIRA)" <ji...@apache.org> on 2012/07/03 15:50:20 UTC

[jira] [Created] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Rick Hillegas created DERBY-5840:
------------------------------------

             Summary: Clean up compiler warnings introduced by using Java 5 language features
                 Key: DERBY-5840
                 URL: https://issues.apache.org/jira/browse/DERBY-5840
             Project: Derby
          Issue Type: Improvement
          Components: Miscellaneous
    Affects Versions: 10.10.0.0
            Reporter: Rick Hillegas


Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421217#comment-13421217 ] 

Knut Anders Hatlen commented on DERBY-5840:
-------------------------------------------

Committed revision 1364917.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff, derby-5840-04-aa-client-level.diff, derby-5840-05-aa-client-deprecation.diff, derby-5840-06-aa-jdbc3-stubs.diff, derby-5840-07-aa-drda-for-each.diff, derby-5840-08-aa-jdbc3-embedded.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-5840:
--------------------------------------

    Attachment: derby-5840-03-ab-drda.diff

Attaching an updated version of the 03-aa patch as 03-ab.

The updated patch makes classlister skip the org.apache.derby.mbeans package (but not the org.apache.derby.mbeans.drda package) when building derbynet.jar.

I've verified that "java -jar derbynet start" works again and that the jars contain the same classes as they did before the patch.

I've started a new regression test run with the updated patch.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13416031#comment-13416031 ] 

Knut Anders Hatlen commented on DERBY-5840:
-------------------------------------------

Committed the 04-aa-client-level and 05-aa-client-deprecation patches to trunk, revision 1362419 and 1362420.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff, derby-5840-04-aa-client-level.diff, derby-5840-05-aa-client-deprecation.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13418171#comment-13418171 ] 

Knut Anders Hatlen commented on DERBY-5840:
-------------------------------------------

Committed the 07-aa patch to trunk with revision 1363264.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff, derby-5840-04-aa-client-level.diff, derby-5840-05-aa-client-deprecation.diff, derby-5840-06-aa-jdbc3-stubs.diff, derby-5840-07-aa-drda-for-each.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-5840:
--------------------------------------

    Attachment: derby-5840-02-aa-compatibilityTests-again.diff.txt

For my own education, I went through the changes in the 01-aa patch to understand exactly why the compiler warned us. I found that some of the code touched by the patch could be made simpler now that they are using Java 5 features. Attaching the patch as 02-aa.

JDBCDriverTest.java: The parameter that caused the warning was always null, so I just removed it.

VersionCombinationConfigurator.java: Used the more specific type URL instead of Object so that no cast was needed.

VersionedNetworkServerTestSetup.java: Removed casts when calling cmd.toArray(new String[cmd.size()]), as the compiler now knows the returned array is a String[].

_Suite.java: Replaced the reference to Collections.EMPTY_LIST with a call to Collections.emptyList(), as the latter is type safe. Also removed the SuppressWarnings annotation since the change to emptyList() silenced the warning.

The tests ran cleanly and I didn't see any warnings when doing a full build.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-5840:
--------------------------------------

    Attachment: derby-5840-08-aa-jdbc3-embedded.diff

Attaching another patch (derby-5840-08-aa-jdbc3-embedded.diff) to compile the JDBC 3-specific classes in the embedded driver with source and target level 1.5.

Source and target level was changed to 1.5 for the JDBC 3 targets in the java/engine sub-tree.

Since we don't produce a separate JDBC 2 driver anymore, the patch folds the JDBC 2 build targets into the JDBC 3 build targets, so that the JDBC 2 classes are also compiled with level 1.5.

In addition to the usual updates to use generics where we get unchecked conversion warnings, the patch fixes a deprecation warning that popped up in EmbeddedDriver.boot(). The warning was about the use of DriverManager.getLogStream(), which is deprecated in favour of DriverManager.getLogWriter(). The patch makes it use getLogWriter(), and changes the signatures of the methods that receive the log writer to expect a PrintWriter instead of a PrintStream. Some places where System.err is passed to those methods, we now have to wrap System.err in a PrintWriter instance because of this.

Changing the target level revealed that our build doesn't properly isolate the JSR-169 implementation classes from the JDBC 3.0 implementation classes, something that manifested itself as failure to boot the engine on J2ME platforms because it tried to load classes that were compiled with a higher target level than the JVM understood. These things had to be fixed to get the engine to load again on J2ME:

1) EmbedConnection30 and EmbedSavepoint30 are used by the JSR-169 implementation, but the classes are compiled by the compile_jdbc3 target, because that target picks up every file whose name matches *30.java. This was addressed by renaming EmbedSavepoint30 to EmbedSavepoint, move all of EmbedConnection30's methods to the super-class (EmbedConnection), and remove the EmbedConnection30 class. Since the class names no longer indicated that this was JDBC 3-specific code (which it wasn't), it was correctly compiled for JSR-169.

2) The XactFactory class failed to load on J2ME because it had a field (xa_resource) whose type was XAResourceManager. We don't support XA in our JSR-169 driver, so XAResourceManager is compiled with target level 1.5, and this prevented the XactFactory class from loading. The fix was to change the type of the field to Object. Using Object instead of XAResourceManager is an existing strategy in XactFactory, as can be seen for example in this method declaration:

    public /* XAResourceManager */ Object getXAResourceManager()

(Note XAResourceManager is commented out.) I assume this was done for a similar reason, perhaps back when JDBC 3 was compiled with target level 1.4, and we still supported Foundation Profile 1.0, which only supported level 1.3.

3) ResourceAdapter (another XA class) is loaded as an optional component, as seen in BasicDatabase.bootResourceAdapter():

		try
		{
			resourceAdapter = 
				Monitor.bootServiceModule(create, this,
										 org.apache.derby.iapi.reference.Module.ResourceAdapter,
										 allParams);
		}
		catch (StandardException mse)
		{
			// OK, resourceAdapter is an optional module
		}

However, even though it was prepared for failure to load the class, this code didn't see a StandardException on J2ME after ResourceAdapter's target level changed to 1.5. Instead, it saw a raw UnsupportedClassVersionError. The fix was to change ProtocolKey.create() to wrap LinkageError (a super-class of UnsupportedClassVersionError) in a StandardException. That method was already prepared for class loading to fail, but not because of wrong class version. When the error came out as a StandardException, BasicDatabase.bootResourceAdapter() knew how to handle it.

I ran suites.All on Oracle Java ME Embedded Client 1.1 to verify that the JSR-169 driver still works. I also ran derbyall and suites.All on Java 5 and Java 7. All the tests passed.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff, derby-5840-04-aa-client-level.diff, derby-5840-05-aa-client-deprecation.diff, derby-5840-06-aa-jdbc3-stubs.diff, derby-5840-07-aa-drda-for-each.diff, derby-5840-08-aa-jdbc3-embedded.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13406066#comment-13406066 ] 

Dag H. Wanvik commented on DERBY-5840:
--------------------------------------

I checked this and saw that the Lint warnings disappeared for the patch. Looks good to me. +1

                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-5840:
--------------------------------------

    Attachment: derby-5840-06-aa-jdbc3-stubs.diff

The 04 patch broke the build if the JDK was newer than Java 5 and no ant.properties file pointing to a Java 5 installation was present.

The reason for the build break was that some JDBC methods actually changed between Java 1.4.2 and Java 5:

CallableStatement.getObject(String, Map) -> Object
CallableStatement.getObject(int, Map) -> Object
Connection.setTypeMap(Map) -> void
Connection.getTypeMap() -> Map

In all of these signatures, Map was changed to Map<String,Class<?>> in Java 5.

When we changed the source level of the client's implementation of these interfaces, and the build used the real Java 5 libraries, we got warnings about unchecked conversions because the implementation classes did not have generic signatures. So the 04 patch changed the signatures to silence the warnings.

However, if we compile using the stubs, which still use non-generic signatures, we get a build error because the compiler doesn't find that we have implemented that method with a more specific signature.

The fix is to update the signatures in the JDBC 3.0 stubs to match the signatures in Java 5, so that we get the same results regardless of which libraries we compile against. The JDBC 3.0 stubs are no longer used to compile code that should run on older JVMs, so it should be a safe move.

derby-5840-06-aa-jdbc3-stubs.diff does that by changing the signatures of the above mentioned methods to use generics.

The patch also changes the source and target level in the build target for the stubs (in order to be allowed to use generic signatures in the code), and fixes a variable declaration in the java.sql.DriverManager stub in order to silence a warning that appeared because of the changed source level.

Committed revision 1362464.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff, derby-5840-04-aa-client-level.diff, derby-5840-05-aa-client-deprecation.diff, derby-5840-06-aa-jdbc3-stubs.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13409337#comment-13409337 ] 

Knut Anders Hatlen commented on DERBY-5840:
-------------------------------------------

Committed the 02-aa patch with revision 1359069.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-5840:
--------------------------------------

    Attachment: derby-5840-05-aa-client-deprecation.diff
                derby-5840-04-aa-client-level.diff

I mentioned that I had tried to change the source level for the network client and found that it caused a lot of deprecation warnings to pop up, even though the methods were deprecated before Java 5. I found an explanation in this bug report: http://bugs.sun.com/view_bug.do?bug_id=6394563

The compile target in java/client/build.xml specifies nowarn="on", which is supposed to silence warnings. However, it only silences non-mandatory warnings, and deprecation warnings became mandatory in Java 5. So when source level changes from 1.4 to 1.5, the compiler isn't allow to ignore the deprecation warnings.

The attached patches change the source and target level for the network client code to 1.5, and clean up the warnings. I've split this change in two separate patches so that it's easier to see which changes are for generics/unchecked conversion warnings, and which changes are for the deprecation warnings.

derby-5840-04-aa-client-level.diff changes the compiler level and addresses the unchecked conversion warnings by using generics in signatures.

One thing to note is that it removes the getTypeMap() implementations in LogicalConnection40 and NetConnection40, as the getTypeMap() implementations in their respective super-classes now have the correct generic signature and no overrides are needed anymore.

derby-5840-05-aa-client-deprecation.diff cleans up the deprecation warnings. There were three kinds of warnings:

- Use of deprecated class java.io.StringBufferInputStream in Clob, ClobOutputStream and ClobWriter. This code is only used when accessing clobs on an old server that doesn't support locators, so I just silenced them using a @SuppressWarnings("deprecation") annotation for now. I did however refactor the code so that the annotation only had to be added at one isolated location.

- LogicalCallableStatement and LogicalPreparedStatement implement some deprecated methods (which they have to implement in order to satisfy the interface), and the compiler complains because they are implemented by forwarding the calls to deprecated methods in the physical statement classes. Adding @Deprecated annotations to the methods in the logical statement classes silences the warnings, as calling deprecated methods from other deprecated methods does not cause warnings.

- The ResultSet class uses deprecated methods in java.util.Date. The patch makes it use non-deprecated methods in java.util.Calendar instead.

The regression tests ran cleanly with these patches, and the compiler didn't emit any warnings.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff, derby-5840-04-aa-client-level.diff, derby-5840-05-aa-client-deprecation.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Hillegas updated DERBY-5840:
---------------------------------

    Attachment: derby-5840-01-aa-compatibilityTests.diff

Attaching derby-5840-01-aa-compatibilityTests.diff. This patch fixes some unchecked compiler warnings in the compatibility tests. Committed at subversion revision 1356735.

Most of the fixes involve adding parameter types to Collection declarations.

However, I added @SuppressWarnings annotations to a couple methods in order to silence the compiler. The root cause of the warnings was that Collections methods were being called on Collections whose parameter types were compiled at level 1.4. These annotations are needed until we can use a Java 5 compiler to build the packages which contain the parameter types.

Touches the following files:

M       java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/VersionedNetworkServerTestSetup.java
M       java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/_Suite.java
M       java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/VersionCombinationConfigurator.java
M       java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/JDBCDriverTest.java

                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13413816#comment-13413816 ] 

Knut Anders Hatlen commented on DERBY-5840:
-------------------------------------------

I found that I got a sealing violation error when I tried to start the network server with "java -jar derbynet.jar start" after applying the 03-aa patch:

$ java -jar derbynet.jar start
Fri Jul 13 16:12:58 CEST 2012 : Security manager installed using the Basic server security policy.
Exception in thread "main" java.lang.ExceptionInInitializerError
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:186)
	at org.apache.derby.impl.drda.NetworkServerControlImpl.startNetworkServer(NetworkServerControlImpl.java:1008)
	at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(NetworkServerControlImpl.java:711)
	at org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(NetworkServerControlImpl.java:2226)
	at org.apache.derby.drda.NetworkServerControl.main(NetworkServerControl.java:352)
Caused by: java.lang.SecurityException: sealing violation: package org.apache.derby.mbeans is sealed
	at java.net.URLClassLoader.getAndVerifyPackage(URLClassLoader.java:388)
(...)

The JUnit tests would fail for similar reasons if derbynet.jar appeared before derby.jar on the classpath.

The reason was that org.apache.derby.mbeans.VersionMBean ended up both in derby.jar and derbynet.jar, and it should only be in derby.jar.

NetworkServerControlImpl has a reference to VersionMBean.class, and so it did before the patch:

        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");

When I disassembled the old and the new version of the NetworkServerControlImpl class, I found that the old version, compiled with target level 1.4, had no reference to VersionMBean.class, only to the string "org.apache.derby.mbeans.VersionMBean". The byte code would dynamically load the class when the code that referenced it was invoked. Since there's no reference to the class, classlister couldn't find it. When compiled with target level 1.5, on the other hand, the byte code would have a direct reference to the class instance, and that enables classlister to find the dependency.

I think the fix is to make classlister ignore the org.apache.derby.mbeans package when building the list of classes to include in derbynet.jar. It already has a list of other engine packages to exclude, so we could add the package to that list.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13406088#comment-13406088 ] 

Knut Anders Hatlen commented on DERBY-5840:
-------------------------------------------

Thanks for cleaning this up, Rick. Looks like a good first step on the way to making use of Java 5 language features.

I saw similar warnings a while ago when I looked into changing the source level of the client code to 1.5 (with the ultimate goal of being able to push the java.sql.Wrapper.unwrap() overrides to the base implementation classes, which would allow us to simplify the class hierarchy). What I noticed, though, was that changing the source level also made the compiler emit lots of deprecation warnings, primarily for deprecated methods in java.util.Date. Those methods were also deprecated in Java 1.4, so it wasn't obvious to me why changing the source level would make the warnings show up.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-5840:
--------------------------------------

    Attachment: derby-5840-07-aa-drda-for-each.diff

While I was at it, I went quickly through the network server code to see if there were places where we could use for-each loops, which would make the code more concise. The attached patch, derby-5840-07-aa-drda-for-each.diff, changes the places I found. Note that in one case (NetworkServerControlImpl.checkAddressIsLocal()) I went one step further and replaced the original for loop with a call to contains(). Also, I only touched loops using Enumerations if the original loop was inside a block synchronized on the collection instance, as there's a slight risk that the for-each loop would throw ConcurrentModificationException, which the Enumeration wouldn't throw.

All the regression tests ran cleanly with the patch.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff, derby-5840-04-aa-client-level.diff, derby-5840-05-aa-client-deprecation.diff, derby-5840-06-aa-jdbc3-stubs.diff, derby-5840-07-aa-drda-for-each.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13414894#comment-13414894 ] 

Knut Anders Hatlen commented on DERBY-5840:
-------------------------------------------

Committed the 03-ab patch to trunk with revision 1361925.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff, derby-5840-03-ab-drda.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5840) Clean up compiler warnings introduced by using Java 5 language features

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-5840:
--------------------------------------

    Attachment: derby-5840-03-aa-drda.diff

The network server is only supported on Java 5 and newer since 10.9. The attached patch, derby-5840-03-aa-drda.diff, changes source and target level to 1.5 for all the code under java/drda (except the servlet) and adds type arguments to declarations and constructor calls where it's required in order to silence unchecked conversion warnings.

Some places the patch also removes casts that became unnecessary because of the extra type information available to the compiler, but I didn't spend too much time on tracking down code that could be simplified, as that didn't cause any compiler warnings.

The code compiles with no warnings in my environment, and all the regression tests passed.
                
> Clean up compiler warnings introduced by using Java 5 language features
> -----------------------------------------------------------------------
>
>                 Key: DERBY-5840
>                 URL: https://issues.apache.org/jira/browse/DERBY-5840
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-5840-01-aa-compatibilityTests.diff, derby-5840-02-aa-compatibilityTests-again.diff.txt, derby-5840-03-aa-drda.diff
>
>
> Using Java 5 language features forces us to compile code at level 5 or higher. At this level, the compiler raises warnings not seen at lower levels. This issue is a place to discuss and attach cleanup to eliminate these warnings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira