Update to Java 10.
This commit is contained in:
parent
c97536b0a4
commit
bb816ba617
@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/ecj-4.4.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
|
@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -122,7 +122,8 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=10
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
|
||||
|
@ -51,8 +51,8 @@
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<available classname="java.util.stream.Stream" property="JDK8.present" />
|
||||
<fail unless="JDK8.present" message="Java 1.8 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
<available classname="java.util.stream.Stream" property="JDK10.present" />
|
||||
<fail unless="JDK10.present" message="Java 10 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
</target>
|
||||
|
||||
<target name="init" depends="checkRequirements" description="Create the output directories.">
|
||||
@ -61,7 +61,7 @@
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="Compile the source.">
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="1.8" target="1.8" encoding="UTF-8" />
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="10" target="10" encoding="UTF-8" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="Create the jar files.">
|
||||
|
@ -1,25 +1,9 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
#
|
||||
# You can set a property for a scripting engine by language name.
|
||||
#
|
||||
# Examples:
|
||||
# language.Java.source=1.8
|
||||
###############################################################################
|
||||
|
||||
|
||||
#######################################
|
||||
# L2J_JavaEngine #####################
|
||||
#######################################
|
||||
|
||||
# The prefered java compiler api to use.
|
||||
# The value is a fully qualified name of a class which implements the javax.toold.JavaCompiler and has a zero argument constructor.
|
||||
# When the prefered compiler is not set, the first found compiler is used.
|
||||
# When the prefered compiler is not found, the last found compiler is used.
|
||||
language.Java.preferedCompiler=com.sun.tools.javac.api.JavacTool
|
||||
language.Java.preferedCompiler=org.eclipse.jdt.internal.compiler.tool.EclipseCompiler
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/JavaC.jar
vendored
Normal file
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/JavaC.jar
vendored
Normal file
Binary file not shown.
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/ecj-4.4.2.jar
vendored
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/ecj-4.4.2.jar
vendored
Binary file not shown.
@ -255,7 +255,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom()
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
@ -267,7 +267,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom(long seed)
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
|
@ -205,7 +205,7 @@ public class GameServer
|
||||
}
|
||||
|
||||
// load script engines
|
||||
printSection("Scripting Engines");
|
||||
printSection("Scripting Engine");
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class EventMethodNotification
|
||||
|
||||
private void invoke(Object instance) throws Exception
|
||||
{
|
||||
final boolean wasAccessible = _method.isAccessible();
|
||||
final boolean wasAccessible = _method.canAccess(instance);
|
||||
if (!wasAccessible)
|
||||
{
|
||||
_method.setAccessible(true);
|
||||
|
@ -149,7 +149,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
private Properties loadProperties()
|
||||
{
|
||||
Properties props = null;
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngines.ini"))
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
|
||||
{
|
||||
props = new Properties();
|
||||
props.load(fis);
|
||||
@ -157,7 +157,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
catch (Exception e)
|
||||
{
|
||||
props = null;
|
||||
LOGGER.warning("Couldn't load ScriptEngines.properties: " + e.getMessage());
|
||||
LOGGER.warning("Couldn't load ScriptEngine.ini: " + e.getMessage());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import org.openjavac.tools.Diagnostic;
|
||||
import org.openjavac.tools.DiagnosticCollector;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractExecutionContext;
|
||||
import com.l2jmobius.gameserver.scripting.annotations.Disabled;
|
||||
@ -44,9 +44,41 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(JavaExecutionContext.class.getName());
|
||||
|
||||
private static final List<String> _options = new LinkedList<>();
|
||||
|
||||
JavaExecutionContext(JavaScriptingEngine engine)
|
||||
{
|
||||
super(engine);
|
||||
|
||||
// Set options.
|
||||
addOptionIfNotNull(_options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(_options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(_options, getProperty("cp"), "-cp") && !addOptionIfNotNull(_options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(_options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(_options, getProperty("g"), "-g:");
|
||||
|
||||
// We always set the target JVM to the current running version.
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addOptionIfNotNull(List<String> list, String nullChecked, String before)
|
||||
@ -109,37 +141,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
try (ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8)))
|
||||
{
|
||||
final List<String> options = new LinkedList<>();
|
||||
addOptionIfNotNull(options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(options, getProperty("cp"), "-cp") && !addOptionIfNotNull(options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(options, getProperty("g"), "-g:");
|
||||
|
||||
// we always add the target JVM to the current running version
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
|
||||
// we really need an iterable of files or strings
|
||||
// We really need an iterable of files or strings.
|
||||
final List<String> sourcePathStrings = new LinkedList<>();
|
||||
for (Path sourcePath : sourcePaths)
|
||||
{
|
||||
@ -148,7 +150,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
final StringWriter strOut = new StringWriter();
|
||||
final PrintWriter out = new PrintWriter(strOut);
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, _options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
if (!compilationSuccess)
|
||||
{
|
||||
out.println();
|
||||
|
@ -17,19 +17,17 @@
|
||||
package com.l2jmobius.gameserver.scripting.java;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.openjavac.tools.JavaCompiler;
|
||||
import org.openjavac.tools.javac.api.JavacTool;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractScriptingEngine;
|
||||
import com.l2jmobius.gameserver.scripting.IExecutionContext;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
* @author HorridoJoho, Mobius
|
||||
*/
|
||||
public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
{
|
||||
@ -37,64 +35,20 @@ public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
|
||||
public JavaScriptingEngine()
|
||||
{
|
||||
super("L2J Java Engine", "1.0", "java");
|
||||
super("Java Engine", "10", "java");
|
||||
}
|
||||
|
||||
private void determineCompilerOrThrow()
|
||||
{
|
||||
final String preferedCompiler = getProperty("preferedCompiler");
|
||||
LinkedList<JavaCompiler> allCompilers = null;
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler != null)
|
||||
if (_compiler == null)
|
||||
{
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
allCompilers = new LinkedList<>();
|
||||
allCompilers.add(compiler);
|
||||
_compiler = JavacTool.create();
|
||||
}
|
||||
|
||||
final ServiceLoader<JavaCompiler> thirdPartyCompilers = ServiceLoader.load(JavaCompiler.class);
|
||||
Iterator<JavaCompiler> compilersIterator = thirdPartyCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
if (_compiler == null)
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
if (allCompilers == null)
|
||||
{
|
||||
allCompilers = new LinkedList<>();
|
||||
}
|
||||
allCompilers.add(compilersIterator.next());
|
||||
throw new IllegalStateException("No JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
if (allCompilers != null)
|
||||
{
|
||||
compilersIterator = allCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compiler == null)
|
||||
{
|
||||
throw new IllegalStateException("No javax.tools.JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
_compiler = compiler;
|
||||
}
|
||||
|
||||
private void ensureCompilerOrThrow()
|
||||
|
@ -24,10 +24,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import org.openjavac.tools.FileObject;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
import org.openjavac.tools.JavaFileObject.Kind;
|
||||
import org.openjavac.tools.StandardJavaFileManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -26,7 +26,8 @@ import java.nio.file.Path;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.NestingKind;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/ecj-4.4.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
|
@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -122,7 +122,8 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=10
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
|
||||
|
@ -51,8 +51,8 @@
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<available classname="java.util.stream.Stream" property="JDK8.present" />
|
||||
<fail unless="JDK8.present" message="Java 1.8 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
<available classname="java.util.stream.Stream" property="JDK10.present" />
|
||||
<fail unless="JDK10.present" message="Java 10 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
</target>
|
||||
|
||||
<target name="init" depends="checkRequirements" description="Create the output directories.">
|
||||
@ -61,7 +61,7 @@
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="Compile the source.">
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="1.8" target="1.8" encoding="UTF-8" />
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="10" target="10" encoding="UTF-8" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="Create the jar files.">
|
||||
|
@ -1,25 +1,9 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
#
|
||||
# You can set a property for a scripting engine by language name.
|
||||
#
|
||||
# Examples:
|
||||
# language.Java.source=1.8
|
||||
###############################################################################
|
||||
|
||||
|
||||
#######################################
|
||||
# L2J_JavaEngine #####################
|
||||
#######################################
|
||||
|
||||
# The prefered java compiler api to use.
|
||||
# The value is a fully qualified name of a class which implements the javax.toold.JavaCompiler and has a zero argument constructor.
|
||||
# When the prefered compiler is not set, the first found compiler is used.
|
||||
# When the prefered compiler is not found, the last found compiler is used.
|
||||
language.Java.preferedCompiler=com.sun.tools.javac.api.JavacTool
|
||||
language.Java.preferedCompiler=org.eclipse.jdt.internal.compiler.tool.EclipseCompiler
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
BIN
L2J_Mobius_2.5_Underground/dist/libs/JavaC.jar
vendored
Normal file
BIN
L2J_Mobius_2.5_Underground/dist/libs/JavaC.jar
vendored
Normal file
Binary file not shown.
BIN
L2J_Mobius_2.5_Underground/dist/libs/ecj-4.4.2.jar
vendored
BIN
L2J_Mobius_2.5_Underground/dist/libs/ecj-4.4.2.jar
vendored
Binary file not shown.
@ -255,7 +255,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom()
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
@ -267,7 +267,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom(long seed)
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
|
@ -209,7 +209,7 @@ public class GameServer
|
||||
}
|
||||
|
||||
// load script engines
|
||||
printSection("Scripting Engines");
|
||||
printSection("Scripting Engine");
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class EventMethodNotification
|
||||
|
||||
private void invoke(Object instance) throws Exception
|
||||
{
|
||||
final boolean wasAccessible = _method.isAccessible();
|
||||
final boolean wasAccessible = _method.canAccess(instance);
|
||||
if (!wasAccessible)
|
||||
{
|
||||
_method.setAccessible(true);
|
||||
|
@ -150,7 +150,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
private Properties loadProperties()
|
||||
{
|
||||
Properties props = null;
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngines.ini"))
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
|
||||
{
|
||||
props = new Properties();
|
||||
props.load(fis);
|
||||
@ -158,7 +158,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
catch (Exception e)
|
||||
{
|
||||
props = null;
|
||||
LOGGER.warning("Couldn't load ScriptEngines.properties: " + e.getMessage());
|
||||
LOGGER.warning("Couldn't load ScriptEngine.ini: " + e.getMessage());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import org.openjavac.tools.Diagnostic;
|
||||
import org.openjavac.tools.DiagnosticCollector;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractExecutionContext;
|
||||
import com.l2jmobius.gameserver.scripting.annotations.Disabled;
|
||||
@ -44,9 +44,41 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(JavaExecutionContext.class.getName());
|
||||
|
||||
private static final List<String> _options = new LinkedList<>();
|
||||
|
||||
JavaExecutionContext(JavaScriptingEngine engine)
|
||||
{
|
||||
super(engine);
|
||||
|
||||
// Set options.
|
||||
addOptionIfNotNull(_options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(_options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(_options, getProperty("cp"), "-cp") && !addOptionIfNotNull(_options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(_options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(_options, getProperty("g"), "-g:");
|
||||
|
||||
// We always set the target JVM to the current running version.
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addOptionIfNotNull(List<String> list, String nullChecked, String before)
|
||||
@ -109,37 +141,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
try (ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8)))
|
||||
{
|
||||
final List<String> options = new LinkedList<>();
|
||||
addOptionIfNotNull(options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(options, getProperty("cp"), "-cp") && !addOptionIfNotNull(options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(options, getProperty("g"), "-g:");
|
||||
|
||||
// we always add the target JVM to the current running version
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
|
||||
// we really need an iterable of files or strings
|
||||
// We really need an iterable of files or strings.
|
||||
final List<String> sourcePathStrings = new LinkedList<>();
|
||||
for (Path sourcePath : sourcePaths)
|
||||
{
|
||||
@ -148,7 +150,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
final StringWriter strOut = new StringWriter();
|
||||
final PrintWriter out = new PrintWriter(strOut);
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, _options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
if (!compilationSuccess)
|
||||
{
|
||||
out.println();
|
||||
|
@ -17,19 +17,17 @@
|
||||
package com.l2jmobius.gameserver.scripting.java;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.openjavac.tools.JavaCompiler;
|
||||
import org.openjavac.tools.javac.api.JavacTool;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractScriptingEngine;
|
||||
import com.l2jmobius.gameserver.scripting.IExecutionContext;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
* @author HorridoJoho, Mobius
|
||||
*/
|
||||
public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
{
|
||||
@ -37,64 +35,20 @@ public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
|
||||
public JavaScriptingEngine()
|
||||
{
|
||||
super("L2J Java Engine", "1.0", "java");
|
||||
super("Java Engine", "10", "java");
|
||||
}
|
||||
|
||||
private void determineCompilerOrThrow()
|
||||
{
|
||||
final String preferedCompiler = getProperty("preferedCompiler");
|
||||
LinkedList<JavaCompiler> allCompilers = null;
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler != null)
|
||||
if (_compiler == null)
|
||||
{
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
allCompilers = new LinkedList<>();
|
||||
allCompilers.add(compiler);
|
||||
_compiler = JavacTool.create();
|
||||
}
|
||||
|
||||
final ServiceLoader<JavaCompiler> thirdPartyCompilers = ServiceLoader.load(JavaCompiler.class);
|
||||
Iterator<JavaCompiler> compilersIterator = thirdPartyCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
if (_compiler == null)
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
if (allCompilers == null)
|
||||
{
|
||||
allCompilers = new LinkedList<>();
|
||||
}
|
||||
allCompilers.add(compilersIterator.next());
|
||||
throw new IllegalStateException("No JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
if (allCompilers != null)
|
||||
{
|
||||
compilersIterator = allCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compiler == null)
|
||||
{
|
||||
throw new IllegalStateException("No javax.tools.JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
_compiler = compiler;
|
||||
}
|
||||
|
||||
private void ensureCompilerOrThrow()
|
||||
|
@ -24,10 +24,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import org.openjavac.tools.FileObject;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
import org.openjavac.tools.JavaFileObject.Kind;
|
||||
import org.openjavac.tools.StandardJavaFileManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -26,7 +26,8 @@ import java.nio.file.Path;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.NestingKind;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/ecj-4.4.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
|
@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -122,7 +122,8 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=10
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
|
||||
|
@ -51,8 +51,8 @@
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<available classname="java.util.stream.Stream" property="JDK8.present" />
|
||||
<fail unless="JDK8.present" message="Java 1.8 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
<available classname="java.util.stream.Stream" property="JDK10.present" />
|
||||
<fail unless="JDK10.present" message="Java 10 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
</target>
|
||||
|
||||
<target name="init" depends="checkRequirements" description="Create the output directories.">
|
||||
@ -61,7 +61,7 @@
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="Compile the source.">
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="1.8" target="1.8" encoding="UTF-8" />
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="10" target="10" encoding="UTF-8" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="Create the jar files.">
|
||||
|
@ -1,25 +1,9 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
#
|
||||
# You can set a property for a scripting engine by language name.
|
||||
#
|
||||
# Examples:
|
||||
# language.Java.source=1.8
|
||||
###############################################################################
|
||||
|
||||
|
||||
#######################################
|
||||
# L2J_JavaEngine #####################
|
||||
#######################################
|
||||
|
||||
# The prefered java compiler api to use.
|
||||
# The value is a fully qualified name of a class which implements the javax.toold.JavaCompiler and has a zero argument constructor.
|
||||
# When the prefered compiler is not set, the first found compiler is used.
|
||||
# When the prefered compiler is not found, the last found compiler is used.
|
||||
language.Java.preferedCompiler=com.sun.tools.javac.api.JavacTool
|
||||
language.Java.preferedCompiler=org.eclipse.jdt.internal.compiler.tool.EclipseCompiler
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
BIN
L2J_Mobius_3.0_Helios/dist/libs/JavaC.jar
vendored
Normal file
BIN
L2J_Mobius_3.0_Helios/dist/libs/JavaC.jar
vendored
Normal file
Binary file not shown.
BIN
L2J_Mobius_3.0_Helios/dist/libs/ecj-4.4.2.jar
vendored
BIN
L2J_Mobius_3.0_Helios/dist/libs/ecj-4.4.2.jar
vendored
Binary file not shown.
@ -255,7 +255,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom()
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
@ -267,7 +267,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom(long seed)
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
|
@ -209,7 +209,7 @@ public class GameServer
|
||||
}
|
||||
|
||||
// load script engines
|
||||
printSection("Scripting Engines");
|
||||
printSection("Scripting Engine");
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class EventMethodNotification
|
||||
|
||||
private void invoke(Object instance) throws Exception
|
||||
{
|
||||
final boolean wasAccessible = _method.isAccessible();
|
||||
final boolean wasAccessible = _method.canAccess(instance);
|
||||
if (!wasAccessible)
|
||||
{
|
||||
_method.setAccessible(true);
|
||||
|
@ -150,7 +150,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
private Properties loadProperties()
|
||||
{
|
||||
Properties props = null;
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngines.ini"))
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
|
||||
{
|
||||
props = new Properties();
|
||||
props.load(fis);
|
||||
@ -158,7 +158,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
catch (Exception e)
|
||||
{
|
||||
props = null;
|
||||
LOGGER.warning("Couldn't load ScriptEngines.properties: " + e.getMessage());
|
||||
LOGGER.warning("Couldn't load ScriptEngine.ini: " + e.getMessage());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import org.openjavac.tools.Diagnostic;
|
||||
import org.openjavac.tools.DiagnosticCollector;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractExecutionContext;
|
||||
import com.l2jmobius.gameserver.scripting.annotations.Disabled;
|
||||
@ -44,9 +44,41 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(JavaExecutionContext.class.getName());
|
||||
|
||||
private static final List<String> _options = new LinkedList<>();
|
||||
|
||||
JavaExecutionContext(JavaScriptingEngine engine)
|
||||
{
|
||||
super(engine);
|
||||
|
||||
// Set options.
|
||||
addOptionIfNotNull(_options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(_options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(_options, getProperty("cp"), "-cp") && !addOptionIfNotNull(_options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(_options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(_options, getProperty("g"), "-g:");
|
||||
|
||||
// We always set the target JVM to the current running version.
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addOptionIfNotNull(List<String> list, String nullChecked, String before)
|
||||
@ -109,37 +141,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
try (ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8)))
|
||||
{
|
||||
final List<String> options = new LinkedList<>();
|
||||
addOptionIfNotNull(options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(options, getProperty("cp"), "-cp") && !addOptionIfNotNull(options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(options, getProperty("g"), "-g:");
|
||||
|
||||
// we always add the target JVM to the current running version
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
|
||||
// we really need an iterable of files or strings
|
||||
// We really need an iterable of files or strings.
|
||||
final List<String> sourcePathStrings = new LinkedList<>();
|
||||
for (Path sourcePath : sourcePaths)
|
||||
{
|
||||
@ -148,7 +150,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
final StringWriter strOut = new StringWriter();
|
||||
final PrintWriter out = new PrintWriter(strOut);
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, _options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
if (!compilationSuccess)
|
||||
{
|
||||
out.println();
|
||||
|
@ -17,19 +17,17 @@
|
||||
package com.l2jmobius.gameserver.scripting.java;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.openjavac.tools.JavaCompiler;
|
||||
import org.openjavac.tools.javac.api.JavacTool;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractScriptingEngine;
|
||||
import com.l2jmobius.gameserver.scripting.IExecutionContext;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
* @author HorridoJoho, Mobius
|
||||
*/
|
||||
public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
{
|
||||
@ -37,64 +35,20 @@ public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
|
||||
public JavaScriptingEngine()
|
||||
{
|
||||
super("L2J Java Engine", "1.0", "java");
|
||||
super("Java Engine", "10", "java");
|
||||
}
|
||||
|
||||
private void determineCompilerOrThrow()
|
||||
{
|
||||
final String preferedCompiler = getProperty("preferedCompiler");
|
||||
LinkedList<JavaCompiler> allCompilers = null;
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler != null)
|
||||
if (_compiler == null)
|
||||
{
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
allCompilers = new LinkedList<>();
|
||||
allCompilers.add(compiler);
|
||||
_compiler = JavacTool.create();
|
||||
}
|
||||
|
||||
final ServiceLoader<JavaCompiler> thirdPartyCompilers = ServiceLoader.load(JavaCompiler.class);
|
||||
Iterator<JavaCompiler> compilersIterator = thirdPartyCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
if (_compiler == null)
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
if (allCompilers == null)
|
||||
{
|
||||
allCompilers = new LinkedList<>();
|
||||
}
|
||||
allCompilers.add(compilersIterator.next());
|
||||
throw new IllegalStateException("No JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
if (allCompilers != null)
|
||||
{
|
||||
compilersIterator = allCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compiler == null)
|
||||
{
|
||||
throw new IllegalStateException("No javax.tools.JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
_compiler = compiler;
|
||||
}
|
||||
|
||||
private void ensureCompilerOrThrow()
|
||||
|
@ -24,10 +24,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import org.openjavac.tools.FileObject;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
import org.openjavac.tools.JavaFileObject.Kind;
|
||||
import org.openjavac.tools.StandardJavaFileManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -26,7 +26,8 @@ import java.nio.file.Path;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.NestingKind;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/ecj-4.4.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
|
@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -122,7 +122,8 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=10
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
|
||||
|
@ -51,8 +51,8 @@
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<available classname="java.util.stream.Stream" property="JDK8.present" />
|
||||
<fail unless="JDK8.present" message="Java 1.8 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
<available classname="java.util.stream.Stream" property="JDK10.present" />
|
||||
<fail unless="JDK10.present" message="Java 10 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
</target>
|
||||
|
||||
<target name="init" depends="checkRequirements" description="Create the output directories.">
|
||||
@ -61,7 +61,7 @@
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="Compile the source.">
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="1.8" target="1.8" encoding="UTF-8" />
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="10" target="10" encoding="UTF-8" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="Create the jar files.">
|
||||
|
@ -1,25 +1,9 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
#
|
||||
# You can set a property for a scripting engine by language name.
|
||||
#
|
||||
# Examples:
|
||||
# language.Java.source=1.8
|
||||
###############################################################################
|
||||
|
||||
|
||||
#######################################
|
||||
# L2J_JavaEngine #####################
|
||||
#######################################
|
||||
|
||||
# The prefered java compiler api to use.
|
||||
# The value is a fully qualified name of a class which implements the javax.toold.JavaCompiler and has a zero argument constructor.
|
||||
# When the prefered compiler is not set, the first found compiler is used.
|
||||
# When the prefered compiler is not found, the last found compiler is used.
|
||||
language.Java.preferedCompiler=com.sun.tools.javac.api.JavacTool
|
||||
language.Java.preferedCompiler=org.eclipse.jdt.internal.compiler.tool.EclipseCompiler
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
BIN
L2J_Mobius_4.0_GrandCrusade/dist/libs/JavaC.jar
vendored
Normal file
BIN
L2J_Mobius_4.0_GrandCrusade/dist/libs/JavaC.jar
vendored
Normal file
Binary file not shown.
BIN
L2J_Mobius_4.0_GrandCrusade/dist/libs/ecj-4.4.2.jar
vendored
BIN
L2J_Mobius_4.0_GrandCrusade/dist/libs/ecj-4.4.2.jar
vendored
Binary file not shown.
@ -255,7 +255,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom()
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
@ -267,7 +267,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom(long seed)
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
|
@ -209,7 +209,7 @@ public class GameServer
|
||||
}
|
||||
|
||||
// load script engines
|
||||
printSection("Scripting Engines");
|
||||
printSection("Scripting Engine");
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class EventMethodNotification
|
||||
|
||||
private void invoke(Object instance) throws Exception
|
||||
{
|
||||
final boolean wasAccessible = _method.isAccessible();
|
||||
final boolean wasAccessible = _method.canAccess(instance);
|
||||
if (!wasAccessible)
|
||||
{
|
||||
_method.setAccessible(true);
|
||||
|
@ -150,7 +150,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
private Properties loadProperties()
|
||||
{
|
||||
Properties props = null;
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngines.ini"))
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
|
||||
{
|
||||
props = new Properties();
|
||||
props.load(fis);
|
||||
@ -158,7 +158,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
catch (Exception e)
|
||||
{
|
||||
props = null;
|
||||
LOGGER.warning("Couldn't load ScriptEngines.properties: " + e.getMessage());
|
||||
LOGGER.warning("Couldn't load ScriptEngine.ini: " + e.getMessage());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import org.openjavac.tools.Diagnostic;
|
||||
import org.openjavac.tools.DiagnosticCollector;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractExecutionContext;
|
||||
import com.l2jmobius.gameserver.scripting.annotations.Disabled;
|
||||
@ -44,9 +44,41 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(JavaExecutionContext.class.getName());
|
||||
|
||||
private static final List<String> _options = new LinkedList<>();
|
||||
|
||||
JavaExecutionContext(JavaScriptingEngine engine)
|
||||
{
|
||||
super(engine);
|
||||
|
||||
// Set options.
|
||||
addOptionIfNotNull(_options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(_options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(_options, getProperty("cp"), "-cp") && !addOptionIfNotNull(_options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(_options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(_options, getProperty("g"), "-g:");
|
||||
|
||||
// We always set the target JVM to the current running version.
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addOptionIfNotNull(List<String> list, String nullChecked, String before)
|
||||
@ -109,37 +141,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
try (ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8)))
|
||||
{
|
||||
final List<String> options = new LinkedList<>();
|
||||
addOptionIfNotNull(options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(options, getProperty("cp"), "-cp") && !addOptionIfNotNull(options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(options, getProperty("g"), "-g:");
|
||||
|
||||
// we always add the target JVM to the current running version
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
|
||||
// we really need an iterable of files or strings
|
||||
// We really need an iterable of files or strings.
|
||||
final List<String> sourcePathStrings = new LinkedList<>();
|
||||
for (Path sourcePath : sourcePaths)
|
||||
{
|
||||
@ -148,7 +150,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
final StringWriter strOut = new StringWriter();
|
||||
final PrintWriter out = new PrintWriter(strOut);
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, _options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
if (!compilationSuccess)
|
||||
{
|
||||
out.println();
|
||||
|
@ -17,19 +17,17 @@
|
||||
package com.l2jmobius.gameserver.scripting.java;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.openjavac.tools.JavaCompiler;
|
||||
import org.openjavac.tools.javac.api.JavacTool;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractScriptingEngine;
|
||||
import com.l2jmobius.gameserver.scripting.IExecutionContext;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
* @author HorridoJoho, Mobius
|
||||
*/
|
||||
public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
{
|
||||
@ -37,64 +35,20 @@ public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
|
||||
public JavaScriptingEngine()
|
||||
{
|
||||
super("L2J Java Engine", "1.0", "java");
|
||||
super("Java Engine", "10", "java");
|
||||
}
|
||||
|
||||
private void determineCompilerOrThrow()
|
||||
{
|
||||
final String preferedCompiler = getProperty("preferedCompiler");
|
||||
LinkedList<JavaCompiler> allCompilers = null;
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler != null)
|
||||
if (_compiler == null)
|
||||
{
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
allCompilers = new LinkedList<>();
|
||||
allCompilers.add(compiler);
|
||||
_compiler = JavacTool.create();
|
||||
}
|
||||
|
||||
final ServiceLoader<JavaCompiler> thirdPartyCompilers = ServiceLoader.load(JavaCompiler.class);
|
||||
Iterator<JavaCompiler> compilersIterator = thirdPartyCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
if (_compiler == null)
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
if (allCompilers == null)
|
||||
{
|
||||
allCompilers = new LinkedList<>();
|
||||
}
|
||||
allCompilers.add(compilersIterator.next());
|
||||
throw new IllegalStateException("No JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
if (allCompilers != null)
|
||||
{
|
||||
compilersIterator = allCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compiler == null)
|
||||
{
|
||||
throw new IllegalStateException("No javax.tools.JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
_compiler = compiler;
|
||||
}
|
||||
|
||||
private void ensureCompilerOrThrow()
|
||||
|
@ -24,10 +24,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import org.openjavac.tools.FileObject;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
import org.openjavac.tools.JavaFileObject.Kind;
|
||||
import org.openjavac.tools.StandardJavaFileManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -26,7 +26,8 @@ import java.nio.file.Path;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.NestingKind;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -1,12 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/ecj-4.4.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
<classpathentry including="**/*.java" kind="src" path="dist/game/data/scripts"/>
|
||||
<classpathentry kind="src" path="java"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -123,7 +123,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.source=10
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
|
||||
|
@ -51,8 +51,8 @@
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<available classname="java.util.stream.Stream" property="JDK8.present" />
|
||||
<fail unless="JDK8.present" message="Java 1.8 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
<available classname="java.util.stream.Stream" property="JDK10.present" />
|
||||
<fail unless="JDK10.present" message="Java 10 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
</target>
|
||||
|
||||
<target name="init" depends="checkRequirements" description="Create the output directories.">
|
||||
@ -61,7 +61,7 @@
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="Compile the source.">
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="1.8" target="1.8" encoding="UTF-8" />
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="10" target="10" encoding="UTF-8" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="Create the jar files.">
|
||||
|
23
L2J_Mobius_CT_2.6_HighFive/dist/game/config/ScriptEngine.ini
vendored
Normal file
23
L2J_Mobius_CT_2.6_HighFive/dist/game/config/ScriptEngine.ini
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
###############################################################################
|
||||
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
||||
language.Java.classloader=System
|
||||
#language.Java.classloader=ThreadContext
|
||||
|
||||
# Source compatibility
|
||||
language.Java.source=1.8
|
||||
|
||||
# The java sourcepath, when you have a different datapack root, you must change this too.
|
||||
language.Java.sourcepath=data/scripts
|
||||
|
||||
# The java classpath
|
||||
language.Java.cp=%java.class.path%
|
||||
|
||||
# The debug informations to generate for compiled class files
|
||||
language.Java.g=source,lines,vars
|
@ -1,39 +0,0 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
#
|
||||
# You can set a property for a scripting engine by language name.
|
||||
#
|
||||
# Examples:
|
||||
# language.Java.source=1.8
|
||||
###############################################################################
|
||||
|
||||
|
||||
#######################################
|
||||
# L2J_JavaEngine #####################
|
||||
#######################################
|
||||
|
||||
# The prefered java compiler api to use.
|
||||
# The value is a fully qualified name of a class which implements the javax.toold.JavaCompiler and has a zero argument constructor.
|
||||
# When the prefered compiler is not set, the first found compiler is used.
|
||||
# When the prefered compiler is not found, the last found compiler is used.
|
||||
language.Java.preferedCompiler=com.sun.tools.javac.api.JavacTool
|
||||
language.Java.preferedCompiler=org.eclipse.jdt.internal.compiler.tool.EclipseCompiler
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
||||
language.Java.classloader=System
|
||||
#language.Java.classloader=ThreadContext
|
||||
|
||||
# Source compatibility
|
||||
language.Java.source=1.8
|
||||
|
||||
# The java sourcepath, when you have a different datapack root, you must change this too.
|
||||
language.Java.sourcepath=data/scripts
|
||||
|
||||
# The java classpath
|
||||
language.Java.cp=%java.class.path%
|
||||
|
||||
# The debug informations to generate for compiled class files
|
||||
language.Java.g=source,lines,vars
|
@ -100,7 +100,7 @@ public final class GraciaLoader
|
||||
{
|
||||
try
|
||||
{
|
||||
script.newInstance();
|
||||
script.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ public final class HellboundLoader
|
||||
{
|
||||
try
|
||||
{
|
||||
final Object instance = script.newInstance();
|
||||
final Object instance = script.getDeclaredConstructor().newInstance();
|
||||
if (instance instanceof IAdminCommandHandler)
|
||||
{
|
||||
AdminCommandHandler.getInstance().registerHandler((IAdminCommandHandler) instance);
|
||||
|
BIN
L2J_Mobius_CT_2.6_HighFive/dist/libs/JavaC.jar
vendored
Normal file
BIN
L2J_Mobius_CT_2.6_HighFive/dist/libs/JavaC.jar
vendored
Normal file
Binary file not shown.
BIN
L2J_Mobius_CT_2.6_HighFive/dist/libs/ecj-4.4.2.jar
vendored
BIN
L2J_Mobius_CT_2.6_HighFive/dist/libs/ecj-4.4.2.jar
vendored
Binary file not shown.
@ -255,7 +255,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom()
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
@ -267,7 +267,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom(long seed)
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
|
@ -205,7 +205,7 @@ public class GameServer
|
||||
}
|
||||
|
||||
// load script engines
|
||||
printSection("Scripting Engines");
|
||||
printSection("Scripting Engine");
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
|
@ -147,7 +147,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
private Properties loadProperties()
|
||||
{
|
||||
Properties props = null;
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngines.ini"))
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
|
||||
{
|
||||
props = new Properties();
|
||||
props.load(fis);
|
||||
@ -155,7 +155,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
catch (Exception e)
|
||||
{
|
||||
props = null;
|
||||
LOGGER.warning("Couldn't load ScriptEngines.properties: " + e.getMessage());
|
||||
LOGGER.warning("Couldn't load ScriptEngine.ini: " + e.getMessage());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import org.openjavac.tools.Diagnostic;
|
||||
import org.openjavac.tools.DiagnosticCollector;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractExecutionContext;
|
||||
import com.l2jmobius.gameserver.scripting.annotations.Disabled;
|
||||
@ -44,9 +44,41 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(JavaExecutionContext.class.getName());
|
||||
|
||||
private static final List<String> _options = new LinkedList<>();
|
||||
|
||||
JavaExecutionContext(JavaScriptingEngine engine)
|
||||
{
|
||||
super(engine);
|
||||
|
||||
// Set options.
|
||||
addOptionIfNotNull(_options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(_options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(_options, getProperty("cp"), "-cp") && !addOptionIfNotNull(_options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(_options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(_options, getProperty("g"), "-g:");
|
||||
|
||||
// We always set the target JVM to the current running version.
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addOptionIfNotNull(List<String> list, String nullChecked, String before)
|
||||
@ -109,37 +141,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
try (ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8)))
|
||||
{
|
||||
final List<String> options = new LinkedList<>();
|
||||
addOptionIfNotNull(options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(options, getProperty("cp"), "-cp") && !addOptionIfNotNull(options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(options, getProperty("g"), "-g:");
|
||||
|
||||
// we always add the target JVM to the current running version
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
|
||||
// we really need an iterable of files or strings
|
||||
// We really need an iterable of files or strings.
|
||||
final List<String> sourcePathStrings = new LinkedList<>();
|
||||
for (Path sourcePath : sourcePaths)
|
||||
{
|
||||
@ -148,7 +150,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
final StringWriter strOut = new StringWriter();
|
||||
final PrintWriter out = new PrintWriter(strOut);
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, _options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
if (!compilationSuccess)
|
||||
{
|
||||
out.println();
|
||||
|
@ -17,19 +17,17 @@
|
||||
package com.l2jmobius.gameserver.scripting.java;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.openjavac.tools.JavaCompiler;
|
||||
import org.openjavac.tools.javac.api.JavacTool;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractScriptingEngine;
|
||||
import com.l2jmobius.gameserver.scripting.IExecutionContext;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
* @author HorridoJoho, Mobius
|
||||
*/
|
||||
public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
{
|
||||
@ -37,64 +35,20 @@ public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
|
||||
public JavaScriptingEngine()
|
||||
{
|
||||
super("L2J Java Engine", "1.0", "java");
|
||||
super("Java Engine", "10", "java");
|
||||
}
|
||||
|
||||
private void determineCompilerOrThrow()
|
||||
{
|
||||
final String preferedCompiler = getProperty("preferedCompiler");
|
||||
LinkedList<JavaCompiler> allCompilers = null;
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler != null)
|
||||
if (_compiler == null)
|
||||
{
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
allCompilers = new LinkedList<>();
|
||||
allCompilers.add(compiler);
|
||||
_compiler = JavacTool.create();
|
||||
}
|
||||
|
||||
final ServiceLoader<JavaCompiler> thirdPartyCompilers = ServiceLoader.load(JavaCompiler.class);
|
||||
Iterator<JavaCompiler> compilersIterator = thirdPartyCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
if (_compiler == null)
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
if (allCompilers == null)
|
||||
{
|
||||
allCompilers = new LinkedList<>();
|
||||
}
|
||||
allCompilers.add(compilersIterator.next());
|
||||
throw new IllegalStateException("No JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
if (allCompilers != null)
|
||||
{
|
||||
compilersIterator = allCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compiler == null)
|
||||
{
|
||||
throw new IllegalStateException("No javax.tools.JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
_compiler = compiler;
|
||||
}
|
||||
|
||||
private void ensureCompilerOrThrow()
|
||||
|
@ -24,10 +24,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import org.openjavac.tools.FileObject;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
import org.openjavac.tools.JavaFileObject.Kind;
|
||||
import org.openjavac.tools.StandardJavaFileManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -26,7 +26,8 @@ import java.nio.file.Path;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.NestingKind;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/ecj-4.4.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
|
@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -122,7 +122,8 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=10
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
|
||||
|
@ -51,8 +51,8 @@
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<available classname="java.util.stream.Stream" property="JDK8.present" />
|
||||
<fail unless="JDK8.present" message="Java 1.8 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
<available classname="java.util.stream.Stream" property="JDK10.present" />
|
||||
<fail unless="JDK10.present" message="Java 10 is required. But your version is Java ${ant.java.version} and probably JDK is not installed." />
|
||||
</target>
|
||||
|
||||
<target name="init" depends="checkRequirements" description="Create the output directories.">
|
||||
@ -61,7 +61,7 @@
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="Compile the source.">
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="1.8" target="1.8" encoding="UTF-8" />
|
||||
<javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="10" target="10" encoding="UTF-8" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="Create the jar files.">
|
||||
|
23
L2J_Mobius_Classic_2.0_Saviors/dist/game/config/ScriptEngine.ini
vendored
Normal file
23
L2J_Mobius_Classic_2.0_Saviors/dist/game/config/ScriptEngine.ini
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
###############################################################################
|
||||
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
||||
language.Java.classloader=System
|
||||
#language.Java.classloader=ThreadContext
|
||||
|
||||
# Source compatibility
|
||||
language.Java.source=1.8
|
||||
|
||||
# The java sourcepath, when you have a different datapack root, you must change this too.
|
||||
language.Java.sourcepath=data/scripts
|
||||
|
||||
# The java classpath
|
||||
language.Java.cp=%java.class.path%
|
||||
|
||||
# The debug informations to generate for compiled class files
|
||||
language.Java.g=source,lines,vars
|
@ -1,39 +0,0 @@
|
||||
###############################################################################
|
||||
# Properties retrived with System.getProperty(String) can be used as values
|
||||
# by enclosing the property name with %. Eg.: %java.class.path%
|
||||
#
|
||||
# You can set a property for a scripting engine by language name.
|
||||
#
|
||||
# Examples:
|
||||
# language.Java.source=1.8
|
||||
###############################################################################
|
||||
|
||||
|
||||
#######################################
|
||||
# L2J_JavaEngine #####################
|
||||
#######################################
|
||||
|
||||
# The prefered java compiler api to use.
|
||||
# The value is a fully qualified name of a class which implements the javax.toold.JavaCompiler and has a zero argument constructor.
|
||||
# When the prefered compiler is not set, the first found compiler is used.
|
||||
# When the prefered compiler is not found, the last found compiler is used.
|
||||
language.Java.preferedCompiler=com.sun.tools.javac.api.JavacTool
|
||||
language.Java.preferedCompiler=org.eclipse.jdt.internal.compiler.tool.EclipseCompiler
|
||||
|
||||
# The parent class loader for isolated script class loaders.
|
||||
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
|
||||
# Values: System, ThreadContext or a fully qualified java class name
|
||||
language.Java.classloader=System
|
||||
#language.Java.classloader=ThreadContext
|
||||
|
||||
# Source compatibility
|
||||
language.Java.source=1.8
|
||||
|
||||
# The java sourcepath, when you have a different datapack root, you must change this too.
|
||||
language.Java.sourcepath=data/scripts
|
||||
|
||||
# The java classpath
|
||||
language.Java.cp=%java.class.path%
|
||||
|
||||
# The debug informations to generate for compiled class files
|
||||
language.Java.g=source,lines,vars
|
BIN
L2J_Mobius_Classic_2.0_Saviors/dist/libs/JavaC.jar
vendored
Normal file
BIN
L2J_Mobius_Classic_2.0_Saviors/dist/libs/JavaC.jar
vendored
Normal file
Binary file not shown.
Binary file not shown.
@ -255,7 +255,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom()
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
@ -267,7 +267,7 @@ public final class Rnd
|
||||
|
||||
public ThreadLocalRandom(long seed)
|
||||
{
|
||||
_seedLocal = new ThreadLocal<Seed>()
|
||||
_seedLocal = new ThreadLocal<>()
|
||||
{
|
||||
@Override
|
||||
public final Seed initialValue()
|
||||
|
@ -206,7 +206,7 @@ public class GameServer
|
||||
}
|
||||
|
||||
// load script engines
|
||||
printSection("Scripting Engines");
|
||||
printSection("Scripting Engine");
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class EventMethodNotification
|
||||
|
||||
private void invoke(Object instance) throws Exception
|
||||
{
|
||||
final boolean wasAccessible = _method.isAccessible();
|
||||
final boolean wasAccessible = _method.canAccess(instance);
|
||||
if (!wasAccessible)
|
||||
{
|
||||
_method.setAccessible(true);
|
||||
|
@ -150,7 +150,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
private Properties loadProperties()
|
||||
{
|
||||
Properties props = null;
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngines.ini"))
|
||||
try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
|
||||
{
|
||||
props = new Properties();
|
||||
props.load(fis);
|
||||
@ -158,7 +158,7 @@ public final class ScriptEngineManager implements IGameXmlReader
|
||||
catch (Exception e)
|
||||
{
|
||||
props = null;
|
||||
LOGGER.warning("Couldn't load ScriptEngines.properties: " + e.getMessage());
|
||||
LOGGER.warning("Couldn't load ScriptEngine.ini: " + e.getMessage());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import org.openjavac.tools.Diagnostic;
|
||||
import org.openjavac.tools.DiagnosticCollector;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractExecutionContext;
|
||||
import com.l2jmobius.gameserver.scripting.annotations.Disabled;
|
||||
@ -44,9 +44,41 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(JavaExecutionContext.class.getName());
|
||||
|
||||
private static final List<String> _options = new LinkedList<>();
|
||||
|
||||
JavaExecutionContext(JavaScriptingEngine engine)
|
||||
{
|
||||
super(engine);
|
||||
|
||||
// Set options.
|
||||
addOptionIfNotNull(_options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(_options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(_options, getProperty("cp"), "-cp") && !addOptionIfNotNull(_options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(_options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(_options, getProperty("g"), "-g:");
|
||||
|
||||
// We always set the target JVM to the current running version.
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
_options.add("-target");
|
||||
_options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addOptionIfNotNull(List<String> list, String nullChecked, String before)
|
||||
@ -109,37 +141,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
try (ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8)))
|
||||
{
|
||||
final List<String> options = new LinkedList<>();
|
||||
addOptionIfNotNull(options, getProperty("source"), "-source");
|
||||
addOptionIfNotNull(options, getProperty("sourcepath"), "-sourcepath");
|
||||
if (!addOptionIfNotNull(options, getProperty("cp"), "-cp") && !addOptionIfNotNull(options, getProperty("classpath"), "-classpath"))
|
||||
{
|
||||
addOptionIfNotNull(options, System.getProperty("java.class.path"), "-cp");
|
||||
}
|
||||
addOptionIfNotNull(options, getProperty("g"), "-g:");
|
||||
|
||||
// we always add the target JVM to the current running version
|
||||
final String targetVersion = System.getProperty("java.specification.version");
|
||||
if (!targetVersion.contains("."))
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(targetVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] versionSplit = targetVersion.split("\\.");
|
||||
if (versionSplit.length > 1)
|
||||
{
|
||||
options.add("-target");
|
||||
options.add(versionSplit[0] + '.' + versionSplit[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JavaCompilerException("Could not determine target version!");
|
||||
}
|
||||
}
|
||||
|
||||
// we really need an iterable of files or strings
|
||||
// We really need an iterable of files or strings.
|
||||
final List<String> sourcePathStrings = new LinkedList<>();
|
||||
for (Path sourcePath : sourcePaths)
|
||||
{
|
||||
@ -148,7 +150,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
|
||||
|
||||
final StringWriter strOut = new StringWriter();
|
||||
final PrintWriter out = new PrintWriter(strOut);
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, _options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
|
||||
if (!compilationSuccess)
|
||||
{
|
||||
out.println();
|
||||
|
@ -17,19 +17,17 @@
|
||||
package com.l2jmobius.gameserver.scripting.java;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.openjavac.tools.JavaCompiler;
|
||||
import org.openjavac.tools.javac.api.JavacTool;
|
||||
|
||||
import com.l2jmobius.gameserver.scripting.AbstractScriptingEngine;
|
||||
import com.l2jmobius.gameserver.scripting.IExecutionContext;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
* @author HorridoJoho, Mobius
|
||||
*/
|
||||
public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
{
|
||||
@ -37,64 +35,20 @@ public final class JavaScriptingEngine extends AbstractScriptingEngine
|
||||
|
||||
public JavaScriptingEngine()
|
||||
{
|
||||
super("L2J Java Engine", "1.0", "java");
|
||||
super("Java Engine", "10", "java");
|
||||
}
|
||||
|
||||
private void determineCompilerOrThrow()
|
||||
{
|
||||
final String preferedCompiler = getProperty("preferedCompiler");
|
||||
LinkedList<JavaCompiler> allCompilers = null;
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler != null)
|
||||
if (_compiler == null)
|
||||
{
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
allCompilers = new LinkedList<>();
|
||||
allCompilers.add(compiler);
|
||||
_compiler = JavacTool.create();
|
||||
}
|
||||
|
||||
final ServiceLoader<JavaCompiler> thirdPartyCompilers = ServiceLoader.load(JavaCompiler.class);
|
||||
Iterator<JavaCompiler> compilersIterator = thirdPartyCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
if (_compiler == null)
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
_compiler = compiler;
|
||||
return;
|
||||
}
|
||||
|
||||
if (allCompilers == null)
|
||||
{
|
||||
allCompilers = new LinkedList<>();
|
||||
}
|
||||
allCompilers.add(compilersIterator.next());
|
||||
throw new IllegalStateException("No JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
if (allCompilers != null)
|
||||
{
|
||||
compilersIterator = allCompilers.iterator();
|
||||
while (compilersIterator.hasNext())
|
||||
{
|
||||
compiler = compilersIterator.next();
|
||||
if ((preferedCompiler == null) || compiler.getClass().getName().equals(preferedCompiler))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compiler == null)
|
||||
{
|
||||
throw new IllegalStateException("No javax.tools.JavaCompiler service installed!");
|
||||
}
|
||||
|
||||
_compiler = compiler;
|
||||
}
|
||||
|
||||
private void ensureCompilerOrThrow()
|
||||
|
@ -24,10 +24,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import org.openjavac.tools.FileObject;
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
import org.openjavac.tools.JavaFileObject.Kind;
|
||||
import org.openjavac.tools.StandardJavaFileManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -26,7 +26,8 @@ import java.nio.file.Path;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.NestingKind;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import org.openjavac.tools.JavaFileObject;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/ecj-4.4.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mysql-connector-java-5.1.43.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/c3p0-0.9.5.2.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/JavaC.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mchange-commons-java-0.2.12.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mysql-connector-java-5.1.46.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;archive detectRoot=&quot;true&quot; path=&quot;/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.28.Final.jar&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.archive"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
|
@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/ecj-4.4.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user