• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java compiler somtimes "missing" a source file when compiling several at the same time  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I understand it, when you write a bunch of java classes, some of which reference the others, upon compiling one of them (I have always compiled the one that has the main method in it, the one that makes stuff happen), all the others get compiled (and recompiled even if they've been previously compiled) at that time. This seems to have always held true in my experience so far but a couple of times lately after altering code in a source file and recompiling the same way as always, I've noticed that I've had to sometimes delete the previously compiled file (the resultant class file) in order to "force" the compiler to recompile it. Are there any known reasons that the compiler will "miss" recompiling a source code file? Just to be clear all the files I'm talking about were definitions of java classes - source code files - with .java extentions, and were all connected to the one being compiled, the one that had a main method. And, once the compiler compiled them all, no errors or warnings were reported and the program worked fine. I seriously doubt this is any misbehaviour of the compiler so I'm curious why it might happen every once in a while. Likely something I might be doing as a novice. The one common thing I noticed was that, the couple times it happened, the file that got missed (not the same source code files each time it happened) was one that would be instantiated as an object within a class that would also be instantiated as an object within another class.

Thanks, to whomever answers.
 
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not possible to isolate the cause by simply reading the problem(at least what your perception of the problem is). Could you elaborate as to how many classes you are dealing with, their names, inter-dependencies, package structures, what is actually happening when you try and compile which file? Otherwise it would be hard for me to isolate what the issue is.
 
simon fletcher
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for looking at my question. To be honest though I wasn't really looking for anyone to go through my code for me - which is why I didn't include any - since most of the time I feel a sense of accomplishment from figuring out my own mistakes that outweighs the initial frustration. I was just wondering if there happened to be known circumstances where the java compiler will not recompile all inter-dependant source files (where previously compiled class files exist from a prior compile). If they should always be recompiled then I'd know that, regardless of how correct my code appears (no errors or warnings when compiling and results of running appear perfect everytime), there is something I'm overlooking and I'd look for it.

I did find some references on the Internet related to my question. I guess the first time I looked I wasn't using very good search criteria because I found none then. I discovered a suggestion that using -Xprefer:source will cause all source code files to be recompiled.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have an answer to your question Simon I take it.
 
simon fletcher
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, if I am understanding the -Xprefer:source option correctly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!