rmannibucau edited a comment on issue #9:
URL:
https://github.com/apache/tomcat-jakartaee-migration/issues/9#issuecomment-753469631
The test does not test what i described.
Issue is that the fields of this class are qname so handled by ee regex so
at runtime you get a nosuchfielderror (use a classloader to list field in javax
and jakarta lands).
Can help if you spend too much time on it - thought it was easy originally
but can be faster to do a pr ;):
```
@Test
public void testXPathConstants() throws IOException {
final Migration migration = new Migration();
migration.setEESpecProfile(EESpecProfile.EE);
final String name = XPathConstantClient.class.getName().replace('.',
'/') + ".class";
final File destination = new File(folder.getRoot(), name);
migration.setSource(Paths.get("target/test-classes")
.resolve(name).toFile());
migration.setDestination(destination);
migration.execute();
assertTrue(destination.exists());
final byte[] bytecode = Files.readAllBytes(destination.toPath());
final JavaClass javaClass = new ClassParser(new
ByteArrayInputStream(bytecode), "unknown").parse();
final String constantPool = javaClass.getConstantPool().toString();
// but stay javax since it is the one from the jvm, not the jakarta
one (from xpathconstants dep)
assertTrue(constantPool,
constantPool.contains("CONSTANT_Utf8[1](\"Ljavax/xml/namespace/QName;\")"));
assertTrue(constantPool,
constantPool.contains("CONSTANT_Utf8[1](\"javax/xml/xpath/XPathConstants\")"));
assertFalse(constantPool,
constantPool.contains("CONSTANT_Utf8[1](\"Ljakarta/xml/namespace/QName;\")"));
}
```
and
```
import javax.xml.namespace.QName;
import javax.xml.xpath.XPathConstants;
public class XPathConstantClient {
public void method() {
final QName nodeset = XPathConstants.NODESET;
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]