JPlag icon indicating copy to clipboard operation
JPlag copied to clipboard

Dynamic Loading of Language Frontends & Fixed behavior of JavaC

Open dfuchss opened this issue 2 years ago • 11 comments

This PR resolves two issues:

Dynamic Loading of Language Frontends

In order to use new language frontends in JPlag easily, this PR creates introduces the ServiceLoader API to JPlag (#272 introduced some first idea. This PR realizes the mentioned alternative)

  1. Languages (entry points of the language frontends) have to be annotated with @MetaInfServices and need to have a default constructor.
  2. By doing so we use the ServiceLoader API of Java to load all Language Frontends (in the classpath) to JPlag
  3. for the CLI, we use getShortName() as key
  4. The dependencies between the core algorithm and the frontends has been relaxed

Fixed behavior of JavaC

This PR resolves Issue #467 by disabling the annotation processing of the Java Compiler. This workaround originates from the discussion on stackoverflow.

dfuchss avatar Jun 23 '22 21:06 dfuchss

Its the same problem again as for log4j .. errors will not be generated anymore by Javac

dfuchss avatar Jun 23 '22 22:06 dfuchss

Ok . now it's time for stackoverflow :) Let's wait for more information!

https://stackoverflow.com/questions/72737445/system-java-compiler-behaves-different-depending-on-dependencies-defined-in-mave

dfuchss avatar Jun 23 '22 23:06 dfuchss

@tsaglam resolved issue regarding loading of invalid Java Files (first occurred in #250) See comments in https://github.com/jplag/JPlag/pull/463/commits/541a0e17637a2b5a6dfc50ef1e8e4ca2cfa1d33e and https://stackoverflow.com/questions/72737445/system-java-compiler-behaves-different-depending-on-dependencies-defined-in-mave#

dfuchss avatar Jun 25 '22 09:06 dfuchss

@jplag/maintainer the duplication is only present due to the nature of the language interface :)

dfuchss avatar Jul 16 '22 21:07 dfuchss

@jplag/maintainer in a followup PR we could also remove the direct deps to the front ends (only the CLI should point to them. Other libraries should include the front ends they need, nothing more)

dfuchss avatar Jul 17 '22 01:07 dfuchss

@jplag/maintainer in a followup PR we could also remove the direct deps to the front ends (only the CLI should point to them. Other libraries should include the front ends they need, nothing more)

The core project needs a dependency on the Java frontend for the tests. But for the others, we should be able to do that.

tsaglam avatar Jul 26 '22 12:07 tsaglam

@jplag/maintainer in a followup PR we could also remove the direct deps to the front ends (only the CLI should point to them. Other libraries should include the front ends they need, nothing more)

The core project needs a dependency on the Java frontend for the tests. But for the others, we should be able to do that.

For the tests, yes`.. but for more?

dfuchss avatar Jul 26 '22 13:07 dfuchss

For the tests, yes`.. but for more?

Only for tests afaik.

tsaglam avatar Jul 29 '22 08:07 tsaglam

@jplag/maintainer I've merged all changes of the main branch :)

So it's finally ready for review.

Should we rename any Language to something like JavaLanguage or LanguagJava?

dfuchss avatar Aug 01 '22 22:08 dfuchss

Should we rename any Language to something like JavaLanguage or LanguagJava?

I would wait with that until the practicals are over and we rename/refactor the frontends.

tsaglam avatar Aug 02 '22 06:08 tsaglam