GithubHelp home page GithubHelp logo

Comments (11)

bjhargrave avatar bjhargrave commented on July 29, 2024

I don't think this is an issue we need to worry about.

The string constant is a default value for an annotation element. For example:

https://docs.jboss.org/hibernate/beanvalidation/spec/2.0/api/javax/validation/constraints/AssertFalse.html#message--

This is addressed in the Jakarta Validation API:

https://github.com/eclipse-ee4j/beanvalidation-api/blob/fca91fff18c19c4101ac3b0166b5a86c8626b355/src/main/java/jakarta/validation/constraints/AssertFalse.java#L41

Such default values don't appear in classes using the annotation. Just in the annotation class itself.

While one can use Transformer to try and convert the Jakarta API from "javax" to "jakarta", the is more properly done in the source code for the Jakarta API as above.

So in this case, I don't think there is an issue we need to address.

from transformer.

dblevins avatar dblevins commented on July 29, 2024

User code can define annotations with defaults. In the case of Bean Validation, the API only works by users defining their own annotations that other developers can use. Those user defined bean validation annotations can legally reference any class.

CDI is an API that also encourages users to create annotations to represent qualifiers, stereotypes, scopes, etc. We can't really guarantee that those annotations don't have defaults that may reference javax classes or have strings that need to be replaced. If users of the annotation didn't explicitly set the value and relied on the default, in that scenario all their code would break.

from transformer.

bjhargrave avatar bjhargrave commented on July 29, 2024

I understand that String defaults in annotation defining classes may need transformation. That should fall under the general heading of String constant transformation rather then something special for annotation defaults.

I was referring to the example cited above which is itself already handled by Jakarta source code changes.

from transformer.

dblevins avatar dblevins commented on July 29, 2024

Sorry, didn't mean to close. Was reading #43 attempting to get a better understanding as they seem like the same issue.

from transformer.

dblevins avatar dblevins commented on July 29, 2024

For my benefit as I don't really know the code yet, from a purely user perspective are we saying that if a user references a javax class in a string in a method block or field, we will update that string automatically if the class referenced by the string was renamed. But if the string that references the renamed class is in an annotation or annotation default, they need to handle that themselves and configure it in their string transformations?

Not a challenge, just trying to understand.

from transformer.

dblevins avatar dblevins commented on July 29, 2024

And amen to your comment on #43 "This is unfortunately very hard since strings can be anything while class names can only be class names."

I'm still not clear on what our capabilities are with updating strings; if it is all mapped by the user or if there are some things done automatically and where the line is.

from transformer.

bjhargrave avatar bjhargrave commented on July 29, 2024

The code processes the Constant Pool which hold String constants. It looks for String constant values that are binary type (/ separated), descriptors ((Lclass;)V) and also direct string replacement (for such configured rules).

case ConstantPool.CONSTANT_String : {
StringInfo stringInfo = constants.entry(constantNo);
String inputString = constants.utf8(stringInfo.string_index);
transformCase = "constant"; // dotted package format
String outputString = transformConstantAsDescriptor(inputString,
SignatureRule.ALLOW_SIMPLE_SUBSTITUTION);
if (outputString == null) {
transformCase = "String"; // url format (slashes)
outputString = transformConstantAsBinaryType(inputString,
SignatureRule.ALLOW_SIMPLE_SUBSTITUTION);
if (outputString == null) {
transformCase = "Direct";
outputString = transformDirectString(inputString);
}
}
if (outputString != null) {
constants.entry(constantNo, new StringInfo(constants.utf8Info(outputString)));
modifiedConstants++;
debug(" String: {} -> {}", inputString, outputString);
verbose("String: {} -> {}", inputString, outputString);
} else {
debug("Skip string {} (unchanged)", inputString);
}
break;
}

But this does not cover . separated types (which are not used by the JVM) but are commonly written by users. The String constant in the initial comment here is not even a type name. It is a string which contains something resembling a . separated type name. So absent a direct string rule, it would be unprocessed.

#44 suggests that we probably need more fine grained control over the rules for direct string replacement. This is probably true. We may also want to support more complex string replacements rules including regex to handle certain cases.

from transformer.

dblevins avatar dblevins commented on July 29, 2024

That's super clear. Thanks so much. More complex string replacements would be awesome. If I can think of any clever design ideas, I'll raise another issue.

Appreciate the patience :)

from transformer.

tbitonti avatar tbitonti commented on July 29, 2024

Hi, is this still an issue?

from transformer.

jgallimore avatar jgallimore commented on July 29, 2024

Thanks for the nudge. I suspect its ok, but I'll check on our side and update.

from transformer.

bjhargrave avatar bjhargrave commented on July 29, 2024

Closing since no feedback that the issue still exists.

from transformer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.