#java #migration #good-for-batch-changes #regex-search
I'm going to be doing a migration of some large projects from Java 8 to Java 11. How can Sourcegraph help me?
There were a lot of changes between Java 8 and 11. In particular, there were several packages removed. This example focuses on searching for one example package that was removed.
lang:java import sun.misc.Base64Encoder
lang:java import sun.misc.Base64Encoder
lang:java import\s*sun.misc.Base64Encoder
The previous example finds all "import sun.misc.Base64Encoder" lines. However, the developer could have included everything "import.sun.misc.*", for example. And, even though they imported it, they may not have used it. So we need to look for both an import and a use of the class in the code.
lang:java import\s*sun.misc.(Base64Encoder|*) and Base64Encoder