groovy

Fix warnings about @deprecated methods for DelegatingMetaClass, ProxyMetaClass, and MockProxyMetaClass

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.1-beta-2
  • Component/s: groovy-jdk
  • Labels:
    None
  • Number of attachments :
    0

Description

Building Groovy from source gives 5 warning messages from javac about deprecated methods - enabling the <deprecation> parameter to the <javac> task (see below) reveals that all of these messages are the result of meta class implementations extending or implementing a deprecated method without declaring that the method is deprecated. The fix is very simple - just add the missing @deprecated declaration to DelegatingMetaClass (invokeConstructorAt), ProxyMetaClass (invokeMethod), and MockProxyMetaClass (invokeMethod).

The confusing warning message for GPathResult.java will disappear as a result of fixing DelegatingMetaClass, which is extended by an anonymous inner class, resulting in the warning message that the compiler bizarrely associates with the declaration of the setAttribute method!

[javac] [...]/groovy-core/src/main/groovy/lang/DelegatingMetaClass.java:185: warning: [deprecation] invokeConstructorAt(java.lang.Class,java.lang.Object[]) in groovy.lang.MetaClass has been deprecated
[javac] public Object invokeConstructorAt(Class at, Object[] arguments) {
[javac] ^
[javac] [...]//groovy-core/src/main/groovy/lang/DelegatingMetaClass.java:186: warning: [deprecation] invokeConstructorAt(java.lang.Class,java.lang.Object[]) in groovy.lang.MetaClass has been deprecated
[javac] return this.delegate.invokeConstructorAt(at, arguments);
[javac] ^
[javac] [...]//groovy-core/src/main/groovy/lang/ProxyMetaClass.java:117: warning: [deprecation] invokeMethod(java.lang.Object,java.lang.String,java.lang.Object[]) in groovy.lang.MetaClassImpl has been deprecated
[javac] public Object invokeMethod(final Object object, final String methodName, final Object[] arguments) {
[javac] ^
[javac] [...]//groovy-core/src/main/groovy/mock/interceptor/MockProxyMetaClass.java:32: warning: [deprecation] invokeMethod(java.lang.Object,java.lang.String,java.lang.Object[]) in groovy.lang.MetaClassImpl has been deprecated
[javac] public Object invokeMethod(final Object object, final String methodName, final Object[] arguments) {
[javac] ^
[javac] [...]//groovy-core/src/main/groovy/util/slurpersupport/GPathResult.java:93: warning: [deprecation] invokeConstructorAt(java.lang.Class,java.lang.Object[]) in groovy.lang.MetaClass has been deprecated
[javac] public void setAttribute(final Object object, final String attribute, final Object newValue) {
[javac] ^
[javac] 5 warnings
[echo] Groovyc of main code.

Activity

Hide
Paul King added a comment -

made deprecation='on' the default in the build. removed all warnings. One deprecated javadoc was reverted back as I think it only comes into play once we have MOP 2.0. I left a TODO to examine in its place.

Show
Paul King added a comment - made deprecation='on' the default in the build. removed all warnings. One deprecated javadoc was reverted back as I think it only comes into play once we have MOP 2.0. I left a TODO to examine in its place.
Hide
Paul King added a comment -

No further feedback, assuming fixed

Show
Paul King added a comment - No further feedback, assuming fixed

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: