Commit 406a3a4f authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Bring in suites, launcher, and CLDC.

parent 9ef51e42
Pipeline #39177 passed with stages
in 1 minute and 31 seconds
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.jvm.launch;
import cc.squirreljme.jvm.mle.JarPackageShelf;
import cc.squirreljme.jvm.mle.TaskShelf;
import cc.squirreljme.jvm.mle.brackets.JarPackageBracket;
import cc.squirreljme.jvm.mle.brackets.TaskBracket;
import cc.squirreljme.jvm.mle.constants.TaskPipeRedirectType;
import cc.squirreljme.jvm.suite.DependencyInfo;
import cc.squirreljme.jvm.suite.EntryPoint;
import java.io.InputStream;
import java.util.Objects;
/**
* Base application support which is able to know about and launch other
* applications.
*
* @since 2021/06/13
*/
public abstract class Application
{
/** The JAR this references. */
protected final JarPackageBracket jar;
/** The library information. */
private final __Libraries__ _libraries;
/**
* The application to load.
*
* @param __jar The JAR used.
* @param __libs The libraries to map.
* @throws NullPointerException On null arguments.
* @since 2021/06/13
*/
Application(JarPackageBracket __jar, __Libraries__ __libs)
throws NullPointerException
{
if (__jar == null || __libs == null)
throw new NullPointerException("NARG");
this.jar = __jar;
this._libraries = __libs;
}
/**
* Returns the display name of the application.
*
* @return The display name of the application.
* @since 2020/12/29
*/
public abstract String displayName();
/**
* Returns the entry point of the task.
*
* @return The entry point that represents this application.
* @since 2020/12/29
*/
public abstract EntryPoint entryPoint();
/**
* Returns the dependencies needed for loading
*
* @return Dependencies needed for loading.
* @since 2021/06/13
*/
public abstract DependencyInfo loaderDependencies();
/**
* Returns the loader entry point arguments.
*
* @return Entry point arguments for loading.
* @since 2021/06/13
*/
public abstract String[] loaderEntryArgs();
/**
* Returns the loader entry class.
*
* @return The load entry class, the class which is responsible for
* starting the application.
* @since 2021/06/13
*/
public abstract String loaderEntryClass();
/**
* Returns the stream to the application icon data.
*
* @return The stream for the application data or {@code null} if there is
* no icon.
* @since 2020/12/29
*/
public final InputStream iconStream()
{
String imgRc = this.entryPoint().imageResource();
if (imgRc != null)
return JarPackageShelf.openResource(this.jar, imgRc);
return null;
}
/**
* Indicates that this should not appear on the launcher.
*
* @return If this should not appear on the launcher.
* @since 2020/12/29
*/
public boolean isNoLauncher()
{
return false;
}
/**
* Launches the specified task.
*
* @return The bracket for the task.
* @since 2020/12/29
*/
public final TaskBracket launch()
{
// Find libraries to base off
Library[] libraries = this._libraries.matchDependencies(
this.loaderDependencies(), true);
int numLibs = libraries.length;
// Determine the class path used from this
JarPackageBracket[] classPath = new JarPackageBracket[numLibs + 1];
for (int i = 0; i < numLibs; i++)
classPath[i] = libraries[i].jar;
classPath[numLibs] = this.jar;
// Have the task launch itself
return TaskShelf.start(classPath,
this.loaderEntryClass(),
this.loaderEntryArgs(),
new String[0],
TaskPipeRedirectType.TERMINAL,
TaskPipeRedirectType.TERMINAL);
}
/**
* Returns the SquirrelJME name of the application.
*
* @return The SquirrelJME name of the application.
* @since 2020/12/29
*/
public final String squirrelJMEName()
{
String fromName = Objects.toString(this.displayName(),
Objects.toString(this.entryPoint().name(),
this.entryPoint().entryPoint()));
StringBuilder sb = new StringBuilder(fromName.length());
for (int i = 0, n = fromName.length(); i < n; i++)
{
char c = fromName.charAt(i);
if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
sb.append(c);
else if (c >= 'A' && c <= 'Z')
sb.append((char)('a' + (c - 'A')));
}
// If blank, put something here at least
if (sb.length() <= 0)
sb.append(fromName.hashCode());
return sb.toString();
}
}
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -7,7 +6,7 @@
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
/**
* This contains the list of suites and libraries.
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -7,16 +6,14 @@
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
import cc.squirreljme.jvm.mle.brackets.JarPackageBracket;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.runtime.swm.Configuration;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.InvalidSuiteException;
import cc.squirreljme.runtime.swm.Profile;
import java.io.InputStream;
import cc.squirreljme.jvm.suite.Configuration;
import cc.squirreljme.jvm.suite.DependencyInfo;
import cc.squirreljme.jvm.suite.EntryPoint;
import cc.squirreljme.jvm.suite.InvalidSuiteException;
import cc.squirreljme.jvm.suite.Profile;
import java.util.Map;
import java.util.Objects;
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -7,14 +6,12 @@
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
import cc.squirreljme.jvm.mle.JarPackageShelf;
import cc.squirreljme.jvm.mle.brackets.JarPackageBracket;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.SuiteInfo;
import java.io.InputStream;
import cc.squirreljme.jvm.suite.DependencyInfo;
import cc.squirreljme.jvm.suite.EntryPoint;
import cc.squirreljme.jvm.suite.SuiteInfo;
/**
* Represents a single application that can be launched.
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -7,13 +6,12 @@
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
import cc.squirreljme.jvm.mle.brackets.JarPackageBracket;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.ProvidedInfo;
import cc.squirreljme.runtime.swm.SuiteInfo;
import cc.squirreljme.jvm.suite.DependencyInfo;
import cc.squirreljme.jvm.suite.ProvidedInfo;
import cc.squirreljme.jvm.suite.SuiteInfo;
/**
* This represents a library that can be used as a dependency, this includes
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -7,7 +6,7 @@
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
/**
* This is a listener which specifies when a suite has been scanned in.
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -7,16 +6,17 @@
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
import cc.squirreljme.jvm.manifest.JavaManifest;
import cc.squirreljme.jvm.mle.JarPackageShelf;
import cc.squirreljme.jvm.mle.brackets.JarPackageBracket;
import cc.squirreljme.jvm.mle.exceptions.MLECallError;
import cc.squirreljme.jvm.suite.EntryPoint;
import cc.squirreljme.jvm.suite.EntryPoints;
import cc.squirreljme.jvm.suite.InvalidSuiteException;
import cc.squirreljme.jvm.suite.SuiteInfo;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.runtime.swm.InvalidSuiteException;
import cc.squirreljme.runtime.swm.SuiteInfo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
......@@ -26,7 +26,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import cc.squirreljme.jvm.manifest.JavaManifest;
/**
* This is a scanner which can read all of the application groups that are
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -7,12 +6,12 @@
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
import cc.squirreljme.jvm.mle.brackets.JarPackageBracket;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.MatchResult;
import cc.squirreljme.runtime.swm.SuiteInfo;
import cc.squirreljme.jvm.suite.DependencyInfo;
import cc.squirreljme.jvm.suite.MatchResult;
import cc.squirreljme.jvm.suite.SuiteInfo;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.LinkedList;
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......@@ -15,4 +14,4 @@
* @since 2020/12/28
*/
package cc.squirreljme.runtime.swm.launch;
package cc.squirreljme.jvm.launch;
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm;
package cc.squirreljme.jvm.suite;
import net.multiphasicapps.strings.StringUtils;
import cc.squirreljme.runtime.cldc.util.StringUtils;
/**
* This represents the name of an API.
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm;
package cc.squirreljme.jvm.suite;
import cc.squirreljme.runtime.cldc.util.StringUtils;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.strings.StringUtils;
/**
* This represents a configuration such as CLDC which specifies which base
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm;
package cc.squirreljme.jvm.suite;
import cc.squirreljme.jvm.manifest.JavaManifestAttributes;
import cc.squirreljme.runtime.cldc.util.StringUtils;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
......@@ -17,10 +17,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import net.multiphasicapps.collections.EmptySet;
import net.multiphasicapps.collections.UnmodifiableSet;
import net.multiphasicapps.strings.StringUtils;
import cc.squirreljme.jvm.manifest.JavaManifestAttributes;
/**
* This contains the information which specifies all of the dependencies which
......@@ -31,7 +27,7 @@ import cc.squirreljme.jvm.manifest.JavaManifestAttributes;
public final class DependencyInfo
{
/** The dependencies. */
protected final Set<MarkedDependency> depends;
private final Set<MarkedDependency> _depends;
/** String representation. */
private Reference<String> _string;
......@@ -44,8 +40,8 @@ public final class DependencyInfo
*/
public DependencyInfo(MarkedDependency... __deps)
{
this((__deps == null ? EmptySet.<MarkedDependency>empty() :
Arrays.<MarkedDependency>asList(__deps)));
this(Arrays.<MarkedDependency>asList((__deps == null ?
new MarkedDependency[0] : __deps)));
}
/**
......@@ -67,18 +63,7 @@ public final class DependencyInfo
throw new NullPointerException("NARG");
else
depends.add(d);
this.depends = UnmodifiableSet.<MarkedDependency>of(depends);
}
/**
* Returns the dependency set.
*
* @return The dependency set.
* @since 2017/12/31
*/
public Set<MarkedDependency> dependencies()
{
return this.depends;
this._depends = depends;
}
/**
......@@ -94,7 +79,7 @@ public final class DependencyInfo
if (!(__o instanceof DependencyInfo))
return false;
return this.depends.equals(((DependencyInfo)__o).depends);
return this._depends.equals(((DependencyInfo)__o)._depends);
}
/**
......@@ -104,7 +89,7 @@ public final class DependencyInfo
@Override
public final int hashCode()
{
return this.depends.hashCode();
return this._depends.hashCode();
}
/**
......@@ -115,7 +100,7 @@ public final class DependencyInfo
*/
public final boolean isEmpty()
{
return this.depends.isEmpty();
return this._depends.isEmpty();
}
/**
......@@ -135,9 +120,9 @@ public final class DependencyInfo
// Remove matching dependencies from the input while keeping the
// matching ones
Set<MarkedDependency> depends = new LinkedHashSet<>(this.depends),
Set<MarkedDependency> depends = new LinkedHashSet<>(this._depends),
matched = new LinkedHashSet<>();
for (MarkedProvided p : __prov.provided())
for (MarkedProvided p : __prov)
{
for (Iterator<MarkedDependency> it = depends.iterator();
it.hasNext();)
......@@ -166,7 +151,7 @@ public final class DependencyInfo
public final DependencyInfo noOptionals()
{
// Ignore if there are no dependencies
Set<MarkedDependency> depends = this.depends;
Set<MarkedDependency> depends = this._depends;
if (depends.isEmpty())
return this;
......@@ -194,7 +179,7 @@ public final class DependencyInfo
if (ref == null || null == (rv = ref.get()))
this._string = new WeakReference<>((rv = "Dependencies:" +
this.depends));
this._depends));
return rv;
}
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm;
package cc.squirreljme.jvm.suite;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm;
package cc.squirreljme.jvm.suite;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import cc.squirreljme.jvm.manifest.JavaManifest;
import cc.squirreljme.jvm.manifest.JavaManifestAttributes;
import cc.squirreljme.jvm.manifest.JavaManifestKey;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
/**
* This parses the entry points which are available for usage.
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.swm;
package cc.squirreljme.jvm.suite;
/**
* This represents an internal project name which is used by SquirrelJME.
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------