Skip navigation

We're decompiling .class files using Procyon.

Sometimes, it get's stuck, looping infinitely.

 

So what to do with that?

 

private class DecompileExecutor extends Thread {
    public void cancelDecompilation() {
        this.stop(new NullPointerException());
    }
}

 

(16:33:46) ozizka-FN: jsightler: this.stop(new NullPointerException());
(16:33:52) jsightler: yeah
(16:33:57) ozizka-FN: that makes a thread exit from a loop?
(16:34:22) jsightler: ozizka: I think it will make it throw a spurious NPE wherever it is
(16:34:51) LincolnThree: doesn't look like its thrown. what does stop() do with it?
(16:34:54) LincolnThree: reading javadocs..
(16:35:12) jsightler: lincolnthree: Yeah, it should be thrown by the thread itself, I think
(16:35:22) LincolnThree: jsightler: afaik this will do nothing
(16:35:27) ozizka-FN: That must have come from the darkest corners of consulting :)
(16:35:39) jsightler: lincolnthree: Er, it definitely doesn't do nothing (it does stop the thread in my tests)
(16:35:58) jsightler: ozizka: TBH, it comes over from overusing this method in the java 1.1 days (predeprection :) )
(16:36:08) LincolnThree: jsightler: oh wow. this method is actually still implemented
(16:36:26) jsightler: lincolnthree: Yeah, just dangerous. :)

 

Enjoy

 

WINDUP-343: Fixes for discover properties, and some other issues by jsight · Pull Request #305 · windup/windup · GitHub

Some projects need a priming build - mostly to load the deps, otherwise the tests would fail when looking for it.

While it's typically an error of the tests or a wrong build order / dependencies, sometimes the project is kept such as it's not a biggest issue.

 

Here's how to determine if such priming build is needed.

Basically, you pick one artifact and check for it's existence in local repository.

mvn dependency:get -o -Dartifact=G:A:V

The trick is to feed it the right version.

Well, provided you run this in project's directory, you can use ${project.version}.

 

mvn dependency:get -o -Dartifact=org.jboss.windup.graph:windup-graph:\${project.version}

 

This will return 0 code when it exists, 1 code if it does not.

 

In our project, I needed to polish this in to a build script. So here's my result:

 

##  Determine this script's location ("Tools" home dir).
scriptPath="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
# For the case when called through a symlink
scriptPath=`readlink -f "$scriptPath"`
scriptDir=`dirname $scriptPath`

SETTINGS="-s $scriptDir/settings.xml"

localRepo=""
for val in "$@"
do
    echo $val
    if [[ "$val" == -Dmaven.repo.local=* ]] ; then localRepo=$val; fi
done

## Priming build to avoid WINDUP-322
if ! mvn $SETTINGS $localRepo dependency:get -o -Dartifact=org.jboss.windup.graph:windup-graph:\${project.version} > /dev/null
then
    echo -e "\n\nRunning a priming build...\n\n"
    mvn $SETTINGS $localRepo install -DskipTests
    echo -e "\n\nPriming build finished.\n\n"
fi


set -x
mvn $SETTINGS clean install $localRepo $@

 

Enjoy!

Filter Blog

By date:
By tag: