Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
oh no computer
May 27, 2003

I completely agree with what you are saying, I'm just saying that as far as I understand the problem, he needs to permute a list of distinct integers (or objects) to seed a tournament. You can't have the same team playing twice at the same stage, or leave teams out. Like I say I might be completely misunderstanding him.

I think #cobol (who uses IRC in this day and age?!) probably suggested he shuffle an array to get around this without noticing that he had his Random inside the loop.

There are other ways to achieve this, I was just showing him how to use Collections.shuffle().

oh no computer fucked around with this message at 20:36 on Nov 4, 2008

Adbot
ADBOT LOVES YOU

csammis
Aug 26, 2003

Mental Institution

BELL END posted:

I completely agree with what you are saying, I'm just saying that as far as I understand the problem, he needs to permute a list of distinct integers (or objects) to seed a tournament. You can't have the same team playing twice at the same stage, or leave teams out. Like I say I might be completely misunderstanding him.

I think #cobol (who uses IRC in this day and age?!) probably suggested he shuffle an array to get around this without noticing that he had his Random inside the loop.

If that's the problem to be solved then that makes perfect sense. I think I might have skipped over the "tournament" part and focused on the "random" - if he truly wants randomly placed distinct integers, the shuffle you posted is definitely the way to go and the Random should've been taken out of consideration entirely. #cobol really dropped the ball here <:mad:>

quote:

#cobol (who uses IRC in this day and age?!)

I do, when my cable modem can go five minutes without pissing itself :(

The Light Eternal
Jun 12, 2006

A man who dares to waste one hour of time has not discovered the value of life.
Shuffling should solve the problem. Here's what my output looks like now:
code:
Enter # of players:
8
3
4
5
3
2
1
6
7
I want it to look like this:
code:
Enter # of players:
8
4
5
2
3
1
6
7
8

csammis
Aug 26, 2003

Mental Institution

The Light Eternal posted:

Shuffling should solve the problem. Here's what my output looks like now:
code:
Enter # of players:
8
3
4
5
3
2
1
6
7
I want it to look like this:
code:
Enter # of players:
8
4
5
2
3
1
6
7
8

Do exactly what BELL END posted, starting at 1.

e: unless you're trying to describe some hidden pattern, I can't tell if that '6 7 8' at the end was intentional. What precisely is it that you want? BELL END's method will get you a sequence of numbers from 1 to num, inclusive, that are shuffled randomly.

The Light Eternal
Jun 12, 2006

A man who dares to waste one hour of time has not discovered the value of life.

csammis posted:

Do exactly what BELL END posted, starting at 1.

I made some minor changes to fix all the errors.
code:
List<Integer> array = new List(num);
		for (int i = 0 ; i < num ; i++) 
			{
			array.add(i); 
			}
		Collections.shuffle(array);
What do I put for the second List? I'm getting an error there that says something about List being a parameterized type.

oh no computer
May 27, 2003

List is an interface, you can't instantiate it. What errors was my code throwing out of interest?

csammis
Aug 26, 2003

Mental Institution

The Light Eternal posted:

What do I put for the second List? I'm getting an error there that says something about List being a parameterized type.

What second list? There's only one in the code you posted. Is it a compiler error or an exception? Copy and paste it here.

e: Oh

code:
List<Integer> array = new ArrayList<Integer>();
ArrayList<E> is Java, right? e2: yes it is, that should work

The Light Eternal
Jun 12, 2006

A man who dares to waste one hour of time has not discovered the value of life.

BELL END posted:

List is an interface, you can't instantiate it. What errors was my code throwing out of interest?

ArrayList cannot be resolved to a type.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

The Light Eternal posted:

I made some minor changes to fix all the errors.
code:
List<Integer> array = new List(num);
		for (int i = 0 ; i < num ; i++) 
			{
			array.add(i); 
			}
		Collections.shuffle(array);
What do I put for the second List? I'm getting an error there that says something about List being a parameterized type.

The error about List being parameterized is that you'll have to write new List<Integer>(num), because List expects a type parameter and Java has no mechanism for inferring them from context. Except you'll actually have to write something like new ArrayList<Integer>(num), because as BELL END wrote, List is not a concrete implementation: it's just an abstract interface.

EDIT: and you'll need to add import java.util.ArrayList; to the top of your file.

csammis
Aug 26, 2003

Mental Institution

The Light Eternal posted:

ArrayList cannot be resolved to a type.

Make sure you're importing java.util, and also using Java 5 or higher.

ArrayList javadoc.

The Light Eternal
Jun 12, 2006

A man who dares to waste one hour of time has not discovered the value of life.

csammis posted:

Make sure you're importing java.util, and also using Java 5 or higher.

ArrayList javadoc.

Awesome, the program works perfectly. Thanks everyone for your help.

XRoja
Jan 8, 2002
Grimey Drawer
I'm beating my head into the wall trying to figure out what I'm doing wrong here. Check this out:
code:
    String chromosome = "10q21.13";
    String chrom = "";
    Pattern chromosomePattern = Pattern.compile("^[\\dXY]+");
    Matcher m = chromosomePattern.matcher(chromosome);
    if (m.find()) {
      chrom = m.group();
    }
m.find() always comes back as false. I've tried the pattern ^[\dXY]+ in other regex tools and it works just fine. What am I doing wrong?

huge sesh
Jun 9, 2008

So i'm working on a highway routing problem and it's looking fairly unavoidable that i'm going to be creating somewhere upwards of 300,000 objects (for the NY map, let alone the US) representing intersections that will be shrunk to allow faster queries. I have heard variously that this is a bad idea in java--object creation has a large overhead and the garbage collector will go crazy trying to keep track of everything.

What can be done to ameliorate this? Should I just go ahead and create objects for the new virtual intersections (that represent an aggregate of multiple real intersections) and call finalize() each time an intersection gets concatenated onto another? Can I allocate memory that is beyond the reach of the garbage collector and do my own memory management?

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

huge sesh posted:

So i'm working on a highway routing problem and it's looking fairly unavoidable that i'm going to be creating somewhere upwards of 300,000 objects (for the NY map, let alone the US) representing intersections that will be shrunk to allow faster queries. I have heard variously that this is a bad idea in java--object creation has a large overhead and the garbage collector will go crazy trying to keep track of everything.
Who told you this? Any modern jvm is very very good at creating objects and keeping gc to minimum.

In order (for me, at least) to help in any real capacity, can you answer these questions:

How large are the objects? How much RAM do you have to work with? Do you predict these objects will be very short lived or will they persist throughout the life of the appplication? Also, is this a desktop, server or mobile app?

dancavallaro
Sep 10, 2006
My title sucks

XRoja posted:

I'm beating my head into the wall trying to figure out what I'm doing wrong here. Check this out:
code:
    String chromosome = "10q21.13";
    String chrom = "";
    Pattern chromosomePattern = Pattern.compile("^[\\dXY]+");
    Matcher m = chromosomePattern.matcher(chromosome);
    if (m.find()) {
      chrom = m.group();
    }
m.find() always comes back as false. I've tried the pattern ^[\dXY]+ in other regex tools and it works just fine. What am I doing wrong?

It seemed to work fine for me... I replaced your "chrom = m.group()" with "System.out.println(m.group())" and it printed "10".

huge sesh
Jun 9, 2008

TRex EaterofCars posted:

Who told you this? Any modern jvm is very very good at creating objects and keeping gc to minimum.

In order (for me, at least) to help in any real capacity, can you answer these questions:

How large are the objects? How much RAM do you have to work with? Do you predict these objects will be very short lived or will they persist throughout the life of the appplication? Also, is this a desktop, server or mobile app?

This is a desktop app running on machines with probably at most 4 gigs of space. I just checked and apparently the USA map has 23 million intersections. These objects will be short-lived -- as soon as i'm finished with each map contraction step I can aggregate them into a single object. anyways, I'll go ahead and proceed with the naive implementation and see how that works with NY and the US.

zootm
Aug 8, 2006

We used to be better friends.

huge sesh posted:

This is a desktop app running on machines with probably at most 4 gigs of space. I just checked and apparently the USA map has 23 million intersections. These objects will be short-lived -- as soon as i'm finished with each map contraction step I can aggregate them into a single object. anyways, I'll go ahead and proceed with the naive implementation and see how that works with NY and the US.
The JVM uses a generational garbage collector so as long as your objects are short-lived they are very easy for it to clean up. It's not trivial (GC can be an issue when latency is a concern) but it's really not a big deal.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
My professor has me doing his sweat shop programming to help his 120 class that are using GameMaker (long story/school sucks). Basically, he wants me to write the chapter examples in the gamemaker book in java. The last one he's given has a guy that runs around an environment top/down style and what you see in the screen is relative to the position of the character.

Is it possible to have a JFrame the size of the screen with a JPanel the size of the level and just have the JPanel repainted in the JFrame to a certain point? It's hard to describe what I'm asking, but if you think about a roguelike, the character approaches the side of the screen but the level shifts over so you can see more to one side. I'm basically trying to recreate this in Java but am not sure how to do the moving environment thing with JFrame/JPanel/JWhatever.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

poemdexter posted:

Is it possible to have a JFrame the size of the screen with a JPanel the size of the level and just have the JPanel repainted in the JFrame to a certain point? It's hard to describe what I'm asking, but if you think about a roguelike, the character approaches the side of the screen but the level shifts over so you can see more to one side. I'm basically trying to recreate this in Java but am not sure how to do the moving environment thing with JFrame/JPanel/JWhatever.


I've never done exactly this, but try using JViewport, which is designed to do this sort of thing inside scrolling panes.

mister_gosh
May 24, 2002

I think I'm having a very fundamental misunderstanding about Java.

I have a servlet which calls another class in a neighboring JAR.

The first time this is executed, everything works great, and my output stream is returned to the caller perfectly.

Any subsequent requests have problems though. The servlet call goes fine, but once the other class is called, problems are found and my application fails.

If I restart Tomcat, execute again, everything is fine until I submit again.

So, I think this is a java class perhaps never picking up after itself and staying instantiated(?). If that's the case, how do I kill it upon successful completion?

Mill Town
Apr 17, 2006

mister_gosh posted:

I think I'm having a very fundamental misunderstanding about Java.

I have a servlet which calls another class in a neighboring JAR.

The first time this is executed, everything works great, and my output stream is returned to the caller perfectly.

Any subsequent requests have problems though. The servlet call goes fine, but once the other class is called, problems are found and my application fails.

If I restart Tomcat, execute again, everything is fine until I submit again.

So, I think this is a java class perhaps never picking up after itself and staying instantiated(?). If that's the case, how do I kill it upon successful completion?

You'll have to be more specific than that. Post the code, and the exact text of the error.

An instance of a class *can* stay instantiated, but that means you have to be holding on to a reference somewhere. Sometimes this is what you want, sometimes it isn't.

(Edit: technically speaking an instance with no references to it can still be sitting around before the garbage collector gets to it, but if your code doesn't still have a reference to it, it shouldn't be able to use it, so you should be able to ignore this situation.)

Actually, in addition to posting your code, you should also post a plain English description of what you *think* it does. It sounds like the sort of problem where you are writing code and expecting it to DWIM.

Mill Town fucked around with this message at 11:23 on Nov 11, 2008

mister_gosh
May 24, 2002

Thanks, for suggesting I post the code, I thought perhaps I was missing something very fundamental, maybe I still am(?). Anyways, I've tried to take out all of the fluff, log4j, comments and variable declarations that didn't make sense to post (for example, retMsg is declared and instantiated).

The servlet:

code:
 public class MyServlet extends HttpServlet {
   
     public void doGet(HttpServletRequest request, HttpServletResponse response) 
                                          throws IOException, ServletException {}    
         
     
     public void doPost(HttpServletRequest request, HttpServletResponse response) 
                                            throws IOException, ServletException {
         
         HttpSession session = request.getSession(true);
                           
         try {
             
             String zipfilename = contentGetter.getContent(path);
             
             retMsg = zipfilename;
             retErr = "";
 
             File f = new File(zipfilename);
             FileInputStream istr = new FileInputStream(zipfilename);
             
             BufferedInputStream bstr = new BufferedInputStream( istr ); // promote
             int size = (int) f.length(); // get the file size (in bytes)
             byte[] bytedata = new byte[size]; // allocate byte array of right size
             bstr.read( bytedata, 0, size ); // read into byte array
             bstr.close();
             
 	     response.setContentType("application/zip");

             response.setHeader("Content-disposition","inline; filename=" + zipfilename);
             response.getOutputStream().write(bytedata);
            
             return;  
                 
         } catch (Exception e) {
            retErr = e.toString();
   	    response.setContentType("text/xml");
  	    response.setHeader("Cache-Control", "no-cache");
 	    response.getWriter().write(BuildReturn(retMsg,retErr));
            return;
         }
             
         
         
     }

     
 }
Here is the class the servlet calls. HERE denotes where most of the problem seems to lie. If I restart Tomcat, this line is successful, the first time, until I submit it again. The 3rd party vendor says there is nothing wrong with their code and suggests it is my servlet.

code:
public class ContentGetter {
     
    public String getContent(String path) {
        String zipFilename = "null";
        
        try {
            String zipFilename = 3rdPartAPICall.GetContent(path); // HERE
        } catch(Exception e) {
            logger.debug("Error "+e.toString());
        }
        return(zipFilename);
    }
 }

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
Where are you declaring a new ContentGetter?

mister_gosh
May 24, 2002

TRex EaterofCars posted:

Where are you declaring a new ContentGetter?

As already stated, I tried to take out the fluff, such as variable declarations. I can tell that it is at the line marked HERE that it fails, based on my log4j output which I've also removed.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

mister_gosh posted:

As already stated, I tried to take out the fluff, such as variable declarations. I can tell that it is at the line marked HERE that it fails, based on my log4j output which I've also removed.

But that particular variable declaration might not be fluff. The only thing I can see that this could even possibly be is a scoping issue.

mister_gosh
May 24, 2002

TRex EaterofCars posted:

But that particular variable declaration might not be fluff. The only thing I can see that this could even possibly be is a scoping issue.

Well, it actually calls another class which does the getContent call. In my servlet, it looks like this:

code:
ServiceTransaction service = new ServiceTransaction();
String zipfilename = service.getService(service, path);
Then in the ServiceTransaction, it queries what the service name is, and then that instantiates the individual service class, in this case the ContentGetter class and then it gets the zipfilename string variable from it.

From my standpoint, I'm wondering if I am cleaning up the servlet code properly, because if I restart Tomcat, it'll work again (one time only).

I've verified that the 3rdPartAPICall is flushed and created new each time (their class has a method which properly exits the call/connection) and that I can properly call other various methods on that 3rd party object, it is a problem specifically when I execute the particular method marked at HERE. So I guess if I am cleaning up properly, it is actually their problem (which they won't admit to).

1337JiveTurkey
Feb 17, 2005

Are you running on an application server such as JBoss? Also, what's the exact error or exception you get? There should be a stacktrace somewhere which tells what went wrong, and that will go a long way towards solving your problems.

mister_gosh
May 24, 2002

code:
COMException= COM IDispatch exception:GetContent() the Perl scripts extraction 
method failed; HRESULT=0x80020009 [Exception occurred.] DISPEXC=[wCode=0 sCode=
-2147220781 description: GetContent() the Perl scripts extraction method failed 
source: 3rdPartyPkg.3rdPartyClass.1] 
Hmmm, upon googling 0x80020009, it suggests it may be a DLL error. Sorry, I would've googled sooner, but I was suspecting I was not closing my class properly. Perhaps it is their DLL not closing properly. I guess the DLL issue gets cleared when Tomcat is restarted...

1337JiveTurkey
Feb 17, 2005

If you're interfacing with native code, make sure that you're using the code exactly like the authors intended. For instance if the library authors just translated some code over using the idioms of the other language without modification, you may be expected to call some cleanup code after every invocation.

Mill Town
Apr 17, 2006

1337JiveTurkey posted:

If you're interfacing with native code, make sure that you're using the code exactly like the authors intended. For instance if the library authors just translated some code over using the idioms of the other language without modification, you may be expected to call some cleanup code after every invocation.

Yeah, I'm guessing 3rdPartAPICall is an object that calls the perl script, yes? Is it a member of a class you've written or is it some pre-existing interface? If it's your own class, post its code too. If it's something someone else wrote, what is the library called and where can we download it or see its documentation?

Also, you should really put the variable declarations back in so we can see where things go in and out of scope.

Fruit Smoothies
Mar 28, 2004

The bat with a ZING
Hey guys, I'm basically a pascal / C kinda guy, and I've just had this java applet planted on me. It has a bug, which I have narrowed down by decompiling (DJ) one of the class files in a cab file.

Naturally, all the strings are named systematically, and I have no idea where the values I'm looking for are. (There are many global variables)

What are my options for debugging a java applet that's already been "compiled"?

Sorry for my blinding ignorance.

1337JiveTurkey
Feb 17, 2005

Fruit Smoothies posted:

Hey guys, I'm basically a pascal / C kinda guy, and I've just had this java applet planted on me. It has a bug, which I have narrowed down by decompiling (DJ) one of the class files in a cab file.

A .cab file? That's new to me. Usually applets are deployed as .jar files. Nevertheless, you could make a project in NetBeans or Eclipse with nothing of its own but containing the .jar file as a library. You can then navigate to the class files in the source tree and they should show the information available at link time and at run time for every single class. Then set the IDE to run the applet, and you should be able to use the debugger, although it may not give much in the way of useful information. The class you want to run as an applet can be found from the tag used to embed the Applet in the web page.

quote:

Naturally, all the strings are named systematically, and I have no idea where the values I'm looking for are. (There are many global variables)

OK, from your use of the term global variables, it sounds like you're thinking of things in a C/Pascal way. There are a million tutorials out there, but for the moment, you can think of objects like records and classes as types of records. I can go into more detail later and answer any questions you might have as well.

quote:

What are my options for debugging a java applet that's already been "compiled"?

Outside of decompiling like you have, the NetBeans/Eclipse project I mentioned earlier has another use. You can get all that information from the .class files because Java keeps it around so that it can dynamically link everything. That means you can also make your own code that links against those class files and verifies that they do what you think they do.

quote:

Sorry for my blinding ignorance.

You're doing pretty good for not knowing the language or having the source, actually.

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

1337JiveTurkey posted:

A .cab file? That's new to me. Usually applets are deployed as .jar files.

It seems that the jar file has everything in it, including the buggy code. Lord knows why I was sent the .cab file.

1337JiveTurkey posted:

...set the IDE to run the applet, and you should be able to use the debugger, although it may not give much in the way of useful information. The class you want to run as an applet can be found from the tag used to embed the Applet in the web page.

Does Eclipse offer step-through debugging?

My only concern is that the code is actually client / server, and the server expects a reply within a certain time, or there's a disconnection that occurs.
Perhaps I'll have to modify the code to write the values to a file for later inspection? Or simply echo them out somewhere.

quote:

OK, from your use of the term global variables, it sounds like you're thinking of things in a C/Pascal way.

What I meant was, I couldn't run the isolated code, because the variables is uses are obviously found elsewhere in the library.
As I said, it's client / server so the values the functions see varies.


EDIT: Do I want Eclipse for java EE, or just for Java?

Fruit Smoothies fucked around with this message at 13:59 on Nov 12, 2008

zootm
Aug 8, 2006

We used to be better friends.

Fruit Smoothies posted:

Does Eclipse offer step-through debugging?
Yep. Double click the left margin of a source file and it'll set a wee blue breakpoint. Debugging works identically to running (just choose "Debug as..." instead of "Run as...").

Fruit Smoothies posted:

EDIT: Do I want Eclipse for java EE, or just for Java?
Java EE includes all of the Java stuff, I think, so that's safer. I doubt you'll need the extra junk it provides though (servlet containers and so on) so probably actually best to just DL the Java one.

Fruit Smoothies
Mar 28, 2004

The bat with a ZING
Ok, so I downloaded Eclipse, and I imported the jar file into a library, however it doesn't seem to be decompiling or showing the functions within. Is this supposed to happen? Or do I need to use the decompiled versions?

EDIT: When I open it, it says damaged / corrupt.

Fruit Smoothies fucked around with this message at 16:15 on Nov 12, 2008

1337JiveTurkey
Feb 17, 2005

Fruit Smoothies posted:

Ok, so I downloaded Eclipse, and I imported the jar file into a library, however it doesn't seem to be decompiling or showing the functions within. Is this supposed to happen? Or do I need to use the decompiled versions?

EDIT: When I open it, it says damaged / corrupt.

Make sure that instead of opening it, you're importing it into the project. Go to the File menu, then select Import... and then from the list of options, select import archive and pick the .jar file. If that doesn't work and you can extract everything by unzipping it, then you can just import the directory tree containing the .class files. You should then see the folders under your package manager and you can look at the specific classes. Since it can't match them back to a source file you'll get something saying Source not found but then it'll list some data like:

code:
// Compiled from Scheduler.java (version 1.4 : 48.0, super bit)
final class org.drools.common.Scheduler {
  
  // Field descriptor #19 Lorg/drools/common/Scheduler;
  private static final org.drools.common.Scheduler INSTANCE;
  
  // Field descriptor #21 Ljava/util/Timer;
  private final java.util.Timer scheduler;
  
  // Method descriptor #23 ()Lorg/drools/common/Scheduler;
  // Stack: 1, Locals: 0
  static org.drools.common.Scheduler getInstance();
    0  getstatic org.drools.common.Scheduler.INSTANCE : org.drools.common.Scheduler [1]
    3  areturn
      Line numbers:
        [pc: 0, line: 45]
  
  // Method descriptor #27 ()V
  // Stack: 4, Locals: 1
  private Scheduler();
     0  aload_0 [this]
     1  invokespecial java.lang.Object() [2]
     4  aload_0 [this]
     5  new java.util.Timer [3]
     8  dup
     9  iconst_1
    10  invokespecial java.util.Timer(boolean) [4]
    13  putfield org.drools.common.Scheduler.scheduler : java.util.Timer [5]
    16  return
      Line numbers:
        [pc: 0, line: 62]
        [pc: 4, line: 63]
        [pc: 16, line: 64]
      Local variable table:
        [pc: 0, pc: 17] local: this index: 0 type: org.drools.common.Scheduler
  
  // Method descriptor #31 (Lorg/drools/common/ScheduledAgendaItem;)V
  // Stack: 6, Locals: 4
  void scheduleAgendaItem(org.drools.common.ScheduledAgendaItem item);
     0  new java.util.Date [6]
     3  dup
     4  invokespecial java.util.Date() [7]
     7  astore_2 [now]
     8  new java.util.Date [6]
    11  dup
    12  aload_2 [now]
    13  invokevirtual java.util.Date.getTime() : long [8]
    16  aload_1 [item]
    17  invokevirtual org.drools.common.ScheduledAgendaItem.getRule() : org.drools.rule.Rule [9]
    20  invokevirtual org.drools.rule.Rule.getDuration() : org.drools.spi.Duration [10]
    23  aload_1 [item]
    24  invokevirtual org.drools.common.ScheduledAgendaItem.getTuple() : org.drools.spi.Tuple [11]
    27  invokeinterface org.drools.spi.Duration.getDuration(org.drools.spi.Tuple) : long [12] [nargs: 2]
    32  ladd
    33  invokespecial java.util.Date(long) [13]
    36  astore_3 [then]
    37  aload_0 [this]
    38  getfield org.drools.common.Scheduler.scheduler : java.util.Timer [5]
    41  aload_1 [item]
    42  aload_3 [then]
    43  invokevirtual java.util.Timer.schedule(java.util.TimerTask, java.util.Date) : void [14]
    46  return
      Line numbers:
        [pc: 0, line: 75]
        [pc: 8, line: 77]
        [pc: 37, line: 79]
        [pc: 46, line: 81]
      Local variable table:
        [pc: 0, pc: 47] local: this index: 0 type: org.drools.common.Scheduler
        [pc: 0, pc: 47] local: item index: 1 type: org.drools.common.ScheduledAgendaItem
        [pc: 8, pc: 47] local: now index: 2 type: java.util.Date
        [pc: 37, pc: 47] local: then index: 3 type: java.util.Date
  
  // Method descriptor #27 ()V
  // Stack: 2, Locals: 0
  static {};
     0  new org.drools.common.Scheduler [15]
     3  dup
     4  invokespecial org.drools.common.Scheduler() [16]
     7  putstatic org.drools.common.Scheduler.INSTANCE : org.drools.common.Scheduler [1]
    10  return
      Line numbers:
        [pc: 0, line: 33]
}

Fruit Smoothies
Mar 28, 2004

The bat with a ZING
Yea I managed to get them listed.

How does this help with debugging though, if I can't see specific source lines?

Incidentally, I have exported .java files with "complete" source. Will this help?

EDIT: When I select "run as -> Applet" i get "No applet". How can this be fixed? I assume it has something to do with the class param in the HTML?

lamentable dustman
Apr 13, 2007

🏆🏆🏆

He was saying to do that so you can figure out the global variable names better. Once you add the jar to the classpath of your project it should show up in the left pane. You should be able to explore the classes inside it. Once you import one of those classes to a new class you can use the code completion feature to get more meaningful global variable names. You obviously won't get the local names though.


Just out of curiosity, how do they expect you to fix the bug without the original source code? Doesn't make sense.

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

dvinnen posted:

He was saying to do that so you can figure out the global variable names better. Once you add the jar to the classpath of your project it should show up in the left pane. You should be able to explore the classes inside it. Once you import one of those classes to a new class you can use the code completion feature to get more meaningful global variable names. You obviously won't get the local names though.


Just out of curiosity, how do they expect you to fix the bug without the original source code? Doesn't make sense.

Ahh I see about the variable names now. As it turns out, the variable names in the class file are already systematic-like, and offer no help what-so-ever.

And I was under the impression that decompiling was 100% accurate with java? (since it's not completely compiled)

Adbot
ADBOT LOVES YOU

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Kinda sorta. It's in between a scripting language and a full compile I guess.

Java is compile down to byte code. This does make decompiling easier but not 100% accurate. Comments are striped of course and I'm sure other optimizations are performed on the code. Variable names are changed to become more machine friendly. The decompiler makes due with these by assigning the variables the same name as the class name.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply