Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 [2]

Author Topic: What is a InstantiationException? Why is it happening to my spawn point?  (Read 7764 times)

kazi

  • Admiral
  • *****
  • Posts: 714
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #15 on: December 05, 2013, 03:30:15 PM »

I'm seriously about to quit this game altogether because of these idiotic error messages I am getting.

Spoiler
Caused by: java.lang.ClassNotFoundException: Compiling unit "data/scripts/world/instrumentalityGen.java"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:212)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:164)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/world/instrumentalityGen.java, Line 100, Column 81: Unknown variable or type "token"

What the *** does it mean it doesn't understand the type token, it's the correct *** entity type to be using there. It appears in that place in every other spawn point reference I can find in every other gen file I've examined. What the hell does it want from me?
[close]
I think I know what may be causing this. I spent 3-4 hours with the same issue until I felt like bashing my head into the keyboard.

It turned out that I was introducing the spawn point into the wrong part of my sectorgen.java file. I was calling my spawn points after the end " } " for the initial "public class."

What was causing the error looked something like this:
Code
<all of the sector generation stuff> 
}
<spawnpoint info>

The error disappeared when I moved the bracket to be like this:
Code
<all of the sector generation stuff> 
<spawnpoint info>
}

Took me a good several hours of troubleshooting to find that. It's not understanding the tokens and other spawnpoint stuff because the file no longer thinks the spawnpoint is part of the sector generation script because of bad bracket placement. At least that was the problem in my case.  :-[
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #16 on: December 05, 2013, 04:55:33 PM »

Just post the WIP of the mod :)

It's really hard to see exactly where you've gone wrong otherwise, but it's almost certainly something small and easily fixed / explained.  Stuff like that error Zaphide pointed out where you're trying to send int, int, instead of float, int is usually fixable by casting the variable to (float) when calling the class, for example.

Logged
Please check out my SS projects :)
Xeno's Mod Pack

oranoron

  • Lieutenant
  • **
  • Posts: 85
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #17 on: December 05, 2013, 05:10:08 PM »

http://www.mediafire.com/download/p338r72jv5au9j5/Instrumentality.7z

don't make fun of my poorly priced out weapons and hulls, I'm still trying to get more data to price them by.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7229
  • Harpoon Affectionado
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #18 on: December 05, 2013, 11:27:20 PM »

I know this all can be frustrating, because the error messages are crap. However:

Install Netbeans.
Setup Netbeans: http://fractalsoftworks.com/forum/index.php?topic=3173.0
NEVER deal with this *** again.

You will fix all of these problems in seconds because the IDE constantly checks your usages. Any errors are underlined in red, with a MUCH better explanation of whats going on.

You'll still need to properly structure things, but no longer will calling or syntax errors ever bother you.
Logged

oranoron

  • Lieutenant
  • **
  • Posts: 85
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #19 on: December 06, 2013, 10:38:37 AM »

Yeah, I honestly don't understand this any better now than before. It is finding so many errors in the files in question I don't know where to event start, I literally can't make heads or tails of what Ive done differently than anyone else unless everyone else is modifying their Fleet API files...


this is my gen file on compile

Spoiler
nt -f "C:\\Users\\Thomas\\Documents\\NetBeansProjects\\Star Sector Mods" -Djavac.includes=data/scripts/world/instrumentalityGen.java -Dnb.internal.action.name=compile.single compile-single
init:
Deleting: C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\build\built-jar.properties
Compiling 1 source file to C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\build\classes
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:9: error: cannot find symbol
public class instrumentalitySpawnPoint extends BaseSpawnPoint {
  symbol: class BaseSpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalityGen.java:103: error: method addScript in interface LocationAPI cannot be applied to given types;
      system.addScript(instrumentalitySpawn);
            ^
  required: EveryFrameScript
  found: instrumentalitySpawnPoint
  reason: actual argument instrumentalitySpawnPoint cannot be converted to EveryFrameScript by method invocation conversion
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:34: error: cannot find symbol
      CampaignFleetAPI fleet = getSector().createFleet("instrumentality", type);
                               ^
  symbol:   method getSector()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:35: error: cannot find symbol
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
                               ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:35: error: cannot find symbol
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
      ^
  symbol:   method getLocation()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:40: error: cannot find symbol
         fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
                                                                         ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:44: error: cannot find symbol
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
                                                                            ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:46: error: cannot find symbol
            fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 20);
                                                                 ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:47: error: cannot find symbol
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
                                                                            ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:16: error: method does not override or implement a method from a supertype
   @Override
   ^
10 errors
C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\nbproject\build-impl.xml:930: The following error occurred while executing this line:
C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\nbproject\build-impl.xml:257: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
[close]

this is my spawn point file on compile

Spoiler
ant -f "C:\\Users\\Thomas\\Documents\\NetBeansProjects\\Star Sector Mods" -Djavac.includes=data/scripts/world/instrumentalitySpawnPoint.java -Dnb.internal.action.name=compile.single compile-single
init:
Deleting: C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\build\built-jar.properties
Compiling 1 source file to C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\build\classes
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:9: error: cannot find symbol
public class instrumentalitySpawnPoint extends BaseSpawnPoint {
  symbol: class BaseSpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:34: error: cannot find symbol
      CampaignFleetAPI fleet = getSector().createFleet("instrumentality", type);
                               ^
  symbol:   method getSector()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:35: error: cannot find symbol
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
                               ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:35: error: cannot find symbol
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
      ^
  symbol:   method getLocation()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:40: error: cannot find symbol
         fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
                                                                         ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:44: error: cannot find symbol
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
                                                                            ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:46: error: cannot find symbol
            fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 20);
                                                                 ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:47: error: cannot find symbol
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
                                                                            ^
  symbol:   method getAnchor()
  location: class instrumentalitySpawnPoint
C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Instrumentality\data\scripts\world\instrumentalitySpawnPoint.java:16: error: method does not override or implement a method from a supertype
   @Override
   ^
9 errors
C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\nbproject\build-impl.xml:930: The following error occurred while executing this line:
C:\Users\Thomas\Documents\NetBeansProjects\Star Sector Mods\nbproject\build-impl.xml:257: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
[close]

Edit: I think I am missing another file somewhere that other people have been using to add references or something but looking through other people's mods I cant figure out what.
« Last Edit: December 06, 2013, 11:22:38 AM by oranoron »
Logged

oranoron

  • Lieutenant
  • **
  • Posts: 85
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #20 on: December 06, 2013, 12:18:45 PM »

OK I'm still getting just as many errors but I think I know what the problem may be related to. The game / netbeans cannot access my Faction file. I think this is why it doesn't know what the "instrumentality" type is. However it is listed in my csv file so I'm not sure.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #21 on: December 06, 2013, 06:45:14 PM »

Here's a fixed version of your mod.  Took longer to set it up in Netbeans than to debug it :)

Highlights:

1.  You need to read the API requirements for various functions. 

2.  You can't use a variable you haven't initialized yet.

Anyhow, here's a working version :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

oranoron

  • Lieutenant
  • **
  • Posts: 85
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #22 on: December 06, 2013, 06:53:43 PM »

You are the best!
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #23 on: December 06, 2013, 07:19:19 PM »

In reply to your bit about "not enough spawns", you need to read the specifications on spawnpoints; basically, there's a variable for how many max fleets to spawn, and you've set it to 1, lol.

See, here, you're creating a new instance of instrumentalitySpawnPoint:
Code: java
system.addSpawnPoint(new instrumentalitySpawnPoint(sector, system, 14f, 1, instrumentalityStation));
See that int maxFleets?  That's what the "1" is controlling.  Change that number above from 1 to 20, voila.
Code: java
instrumentalitySpawnPoint(SectorAPI sector, LocationAPI location, float daysInterval, int maxFleets, SectorEntityToken anchor)
That's what I mean about reading the API stuff; if you're using functions and you don't even know what the numbers / objects mean, you're going to get into trouble, fast.  Just how it goes, but most of this is documented quite nicely in the API :)
« Last Edit: December 06, 2013, 07:21:46 PM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Trylobot

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1170
    • View Profile
    • Github profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #24 on: December 11, 2013, 09:40:16 AM »

@oranoron: If you're trying to develop outside of an IDE, you're always going to have these kinds of headaches. Please follow Thaago's suggestion, and try to setup Netbeans correctly. Yes, there is a tutorial on how to do this.

http://fractalsoftworks.com/forum/index.php?topic=3173.0
Logged

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: What is a InstantiationException? Why is it happening to my spawn point?
« Reply #25 on: December 11, 2013, 10:56:44 AM »

quick guide on how to read an error log

the important bit (tells you what you did wrong)
Code
Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/world/instrumentalityGen.java, 
Line 104, Column 25: No applicable constructor/method found for actual parameters "com.fs.starfarer.api.campaign.SectorAPI,
com.fs.starfarer.api.campaign.StarSystemAPI, int, int, com.fs.starfarer.api.campaign.SectorEntityToken,
com.fs.starfarer.api.campaign.PlanetAPI, com.fs.starfarer.api.campaign.SectorEntityToken"; candidates are:
"data.scripts.world.instrumentalitySpawnPoint(com.fs.starfarer.api.campaign.SectorAPI, com.fs.starfarer.api.campaign.LocationAPI, float,
int, com.fs.starfarer.api.campaign.SectorEntityToken)"

what this means:
you have an error
in the file data/scripts/world/instrumentalityGen.java
at line Line 104
starting with character 25 on that line
what you did wrong: "No applicable constructor/method found for actual parameters"
look under the headings:
Spoiler
"com.fs.starfarer.api.campaign.SectorAPI, com.fs.starfarer.api.campaign.StarSystemAPI, int, int, com.fs.starfarer.api.campaign.SectorEntityToken, com.fs.starfarer.api.campaign.PlanetAPI, com.fs.starfarer.api.campaign.SectorEntityToken"
[close]
in the Starsector Java doc

what it would like to have for you to fix this problem: "data.scripts.world.instrumentalitySpawnPoint(com.fs.starfarer.api.campaign.SectorAPI, com.fs.starfarer.api.campaign.LocationAPI, float, int, com.fs.starfarer.api.campaign.SectorEntityToken)"

the errors you are getting are actualy more or less self explanatory, you should the errors Iget with my scripts, they basicly say "halp it is break desu" with no aditional info

also I agree get netbeans, or IntelliJ IDEA (more usefull for java starters cause its smart(literaly codes for you in some cases))
both are free, but I prefer the later
« Last Edit: December 11, 2013, 11:01:22 AM by dmaiski »
Logged
BISO
(WIP) lots of shiny new weapons ( :-[ i have more weapons then sprites :-[ )

i got a cat pad
its like a mouse pad but better!
Pages: 1 [2]