Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: Cannot Determine Simple Type Name  (Read 8929 times)

billi999

  • Commander
  • ***
  • Posts: 149
    • View Profile
Cannot Determine Simple Type Name
« on: September 09, 2016, 11:17:35 AM »

Hello
I've recently been trying to fix my ship pack to work in a minimal sense (simply having it not crash and work in corvus mode) but have hit a brick wall.

When I don't have the import for
Code
 java.lang 
or
Code
 java.lang.Method 
, I receive the error in the title for the type Method.
When I do have the import, I have the same error only for SectorGeneratorPlugin.
Now I know what you're thinking - easy, something else is wrong with the code which is causing the error. But as far as I can see this isn't the case.
• I have tried commenting out everything around the Method class to eliminate other possible causes.
• setupForCorvus is fine and proven code: when I entirely comment out the current generate() method and rename setupForCorvus to generate, all is fine (as long as you don't have Nexerelin of course).
• I wondered if this was caused by me not having Nexerelin, but then I remembered this is supposed to stop it from crashing, not prevent it from compiling in the first place. Even then the try-catch should stop a horrible runtime death.

My suspicion is I am missing another import for the exceptions.

Here is my code at the moment:
Code
package data.scripts.world;

import java.awt.Color;
import java.util.List;
import java.lang.Method; //This causes the problem, as does import java.lang;
import java.util.ArrayList;
import java.util.Arrays;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.submarkets.StoragePlugin;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import com.fs.starfarer.api.impl.campaign.ids.Factions;

import data.scripts.world.corvus.Corvus;

@SuppressWarnings("unchecked")
public class ShipPackSectorGen implements SectorGeneratorPlugin
//public class ShipPackSectorGen extends SectorGen
{
public void generate(SectorAPI sector)
{
//try
//{
Class<?> def = Global.getSettings().getScriptClassLoader().loadClass("exerelin.campaign.SectorManager");
Method method;
//try
//{
// method = def.getMethod("getCorvusMode");
// Object result = method.invoke(def);
// if ((boolean)result == true)
// {
// setupForCorvus(sector);
// }
//}
//catch (NoSuchMethodException ex) { }
//catch (SecurityException ex) { }
//catch (IllegalAccessException ex) { }
//catch (IllegalArgumentException ex) { }
//catch (InvocationTargetException ex) { }
//}
//catch (ClassNotFoundException ex)
//{
// setupForCorvus(sector);
//}
}

public void setupForCorvus(SectorAPI sector)
{
                ...
                Do a bunch of stuff
                ...
        }
...

Any help with this is much appreciated, this has been driving me nuts for a few days now and I understand it's probably something incredibly simple that I'm missing, so sorry if I'm being dumb.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #1 on: September 09, 2016, 02:17:26 PM »

Could you post the stack trace from the log? This kind of stuff (and, really, anything else that produces a stack trace) is pretty hard to decipher without one.
Logged

billi999

  • Commander
  • ***
  • Posts: 149
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #2 on: September 09, 2016, 03:01:22 PM »

I'm sorry, I totally didn't think of that. Hmm... I'm drawn towards findClass, could that be related to Global.getSettings().getScriptClassLoader().loadClass(...)?

Code
22909 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.world.ShipPackSectorGen]
java.lang.RuntimeException: Error compiling [data.scripts.world.ShipPackSectorGen]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/world/ShipPackSectorGen.java', Line 39, Column 17: Cannot determine simple type name "Method"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/world/ShipPackSectorGen.java', Line 39, Column 17: Cannot determine simple type name "Method"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5398)
at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5207)
at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5188)
at org.codehaus.janino.UnitCompiler.access$12600(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$16.visitReferenceType(UnitCompiler.java:5119)
at org.codehaus.janino.Java$ReferenceType.accept(Java.java:2880)
at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
at org.codehaus.janino.UnitCompiler.getLocalVariable(UnitCompiler.java:1877)
at org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:2552)
at org.codehaus.janino.UnitCompiler.access$4300(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:2434)
at org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:2508)
at org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:2437)
at org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:2395)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2250)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
... 5 more
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #3 on: September 09, 2016, 03:13:24 PM »

java.lang.reflect.Method

I really recommend setting up an IDE, it does these sorts of things for you :) (Edit: yeah, it takes some time to set up and figure out. But in the long time, you're going to end up spending more time tracking down stuff like this...)

Also, this may be a problem:
Class<?> def = Global.getSettings().getScriptClassLoader().loadClass("exerelin.campaign.SectorManager");

Janino (the compiler starsector ships with) does not support generics. Could be fine just removing the bolded part.

« Last Edit: September 09, 2016, 03:23:44 PM by Alex »
Logged

billi999

  • Commander
  • ***
  • Posts: 149
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #4 on: September 09, 2016, 04:16:55 PM »

That did the trick. You're right about using an IDE, would notepad++ be enough or would I need something more? Would Eclipse work?
The point on generics was right too, with the removed it appears to work just fine. If there are further problems I will post, or edit this post if I solve them myself... But only after getting an IDE set up  :-[
Thanks for your time and help as usual Alex!

To anyone else that might be looking to this thread for minimum Nexerelin compatibility: I also had to change the boolean cast to Boolean (note the casing, boolean is a simple type and will not cast properly from the Object type).
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #5 on: September 09, 2016, 05:18:11 PM »

Some tutorials linked here:
http://fractalsoftworks.com/forum/index.php?topic=633.0

They're for setting up Netbeans or IntelliJ. Eclipse would also work, but it'd be rough going without a tutorial.

Not familiar with Notepad++, but I suspect it would be insufficient - it wouldn't know about imports and such, at best it might be able to catch basic syntax errors.
Logged

borgrel

  • Captain
  • ****
  • Posts: 348
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #6 on: September 10, 2016, 12:24:17 AM »

Notepad++ is not an IDE, its just a text highlighter

As long as you disable all of netbeans' stupid javadoc functionality
(and dont expect CTRL+spacebar function finder to work)
netbeans is king!!
Logged

billi999

  • Commander
  • ***
  • Posts: 149
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #7 on: September 10, 2016, 03:24:48 AM »

Thanks a lot guys! Using the Netbeans tutorial loosely for reference I got it working with Eclipse. I even figured out how to compile starferer-core so I could reference it without the risk of editing the core ;D maybe I should make an Eclipse tutorial sometime, although I would have to go through the whole process again and document it properly so that it isn't all over the place.

Thanks again for the help!

Edit: By the way, once the update for my ship pack is finished, is it a fair reason to post in the thread (thus bump), so that others that wish to use the mod with Nexerlin will see an update has been released?

Edit 2: @Alex Sorry about being unclear, reading it again I can see why it would be :) but your guess was totally correct about posting in the thread I already I have. I asked because I know some forums seem to be strict about the whole bumping threads thing.
« Last Edit: September 10, 2016, 11:16:55 AM by billi999 »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot Determine Simple Type Name
« Reply #8 on: September 10, 2016, 10:37:19 AM »

Edit: By the way, once the update for my ship pack is finished, is it a fair reason to post in the thread (thus bump), so that others that wish to use the mod with Nexerlin will see an update has been released?

You've got a thread for it already, right? Probably makes sense to post/bump there, then, unless that's what you mean. Not 100% understanding, but basically feel free to whatever :)
Logged