jetty / jetty/jetty.project

Jetty 12 - Improve method lookup in XmlConfiguration

Open
#8,917 5 comments 0 reactions 0 assignees View on GitHub
Bug Help Wanted Low Priority
Dominant language
Java
Stars
4.1k
Forks
2k
Avg merge
3d 56m
Merged PRs (30d)
48

Description

**Jetty version(s)**
12+

**Description**
Following #8915, the XML has become a little more verbose in those cases where there is need to invoke a method on a JDK private implementation class.

@joakime pointed out that if we do class hierarchy lookup and interface hierarchy lookup, and put the interface methods before the class methods in the correct order (the ones more up in the hierarchy first), then we will find the interface `Method` that is accessible before the private class method, so the invocation will succeed.

We exchange the cost of adding an XML attribute (as it is now) but not doing a complete class/interface lookup, with the cost of always doing a complete class/interface lookup but a a cleaner XML.

Note that we must recursively lookup also interfaces because, assuming `PrivateRunnable` and `ConcreteRunnable` are private JDK classes:

```java
interface PrivateRunnable extends Runnable {}
class ConcreteRunnable implements PrivateRunnable {
public void run() {}
}

// Runnable *not* listed.
ConcreteRunnable.class.getInterfaces() => Class[1] { interface PrivateRunnable }
```

So in order to call the `run()` method on an object of class `ConcreteRunnable`, we must obtain a `Method` object by looking it up from `Runnable.run()`, since neither `ConcreteRunnable.run()` nor `PrivateRunnable.run()` would work.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.