• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javac puzzle

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I've spotted out an unexpected javac behavior, just wanted to share it to get some feedback from you guys, as it's a bit annoying.

So here it is, given the following folders structure and class content:

adir/A.java


bdir/B.java


cdir/C.java


and the following commands:
javac adir/A.java
javac bdir/B.java -cp adir/

then
javac cdir/C.java -cp bdir/
fails with the following:
C.java:3: cannot access A
file A.class not found
B b = new B("");
^
1 error

So even if in B.java, nothing can possibly access an A class (which is anyway NOT in the classpath) or at least access an exposed API from B that involes an A, C.java will not compile!
It gets even wierder because with the following modifications, everything compiles fine:
- Adding an empty constructor to B


- Calling the empty constructor instead of the String one in C


Then javac does not complain anymore and does its job...
Couldn't find anything on internet on that..
Thanks!

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic