groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tatai Márton <tataimarton...@gmail.com>
Subject Purpose of MetaClass.getClassNode
Date Sun, 16 Apr 2017 14:41:48 GMT
Hello,

I was going through the source code of the GROOVY_2_5_X branch, just
studying the inner workings of the runtime. (So if I'm saying something
foolish please excuse my inexperience)
I came across groovy.lang.MetaClass.getClassNode, which strikes me as an
inappropriate method as a part of the runtime. This method seems
potentially useful, but unnecessarily couples compile time to the runtime
apparatus.
As far as static analysis goes, I've found getClassNode used in some tests
for AstBuilder, and as part of some clever tricks in groovy.sql.DataSet.
As I've already established, I'm not an expert at the matter, but I think
the MetaClass interface would be cleaner without this method. I realise
that it's part of a public(?) interface, so deletion might not be an
option, but do you think a deprecation and a stern warning would be
appropriate? The MetaClassImpl implementation of this method only works as
long as the source is available and can be located on the classpath. Even
if this is the case, the compiler is pretty convoluted, and I'm not even
sure that the same AST can be generated at runtime as compile time.
I've tried to look into the history of this method, and a pretty ancient
commit mentions this as a residual feature, which should be removed:
https://github.com/apache/groovy/commit/9ebea0cbddcad1ab6636da61962a368138828bf0#diff-3a2f96e7344aaac477f01c5f7e0d3d88R115

Best regards
Marton

Mime
View raw message