1

I have adapted some java sources but I have detected an issue and I don't know the possible solution solving easily my problem.

I have 2 java class: The first class GCRProperties.java check more easily variables from properties files or environment variable. The second class GCRLogger.java retrieve data from GCRProperties before logging (DEBUG, INFO....).

This solution worked perfectly but I want using class GCRLogger in GCRProperties to log the execution of this class.

At this time, when I want compile GCRProperties, GCRLogger is mandatory and when I want compile GCRLogger, GCRProperties is mandatory.

I'm not a java expert and before implementing an unstable solution, I prefer listening Java experts to have a good solution.

Thanks Gilles

user16785
  • 11
  • 1
  • i could say use create interfaces, but to give you clearer example, add some of your code which describes relation between those two classes – user902383 Mar 14 '14 at 15:01
  • In most cases these sort of circular references are handled automatically by the compiler, unless you are trying to do something very odd. Have you actually tried doing this? You may find it "just works". – Tim B Mar 14 '14 at 15:03
  • Yes it just works.... But I am interested in knowing how! I will keep an eye on this post – Hirak Mar 14 '14 at 15:07
  • http://stackoverflow.com/questions/3032874/how-does-compiling-circular-dependencies-work – Stijn Geukens Mar 14 '14 at 16:29

1 Answers1

0

I assume you have variables that are used in both classes and they are public. What exactly is your question? From the given info, it sounds like it should be fine. Post the code or send it to me if you want a second look. Chances are, it will be fine and the reason why both classes are needed is because they both need references from the other class.

This is a circular dependency from what you are telling me: browse the stack. There is info on this. This should get you started

How does compiling circular dependencies work?

Community
  • 1
  • 1
StreamingBits
  • 137
  • 11