If the black wire in this situation is the ungrounded (hot) conductor, then it's a possible code violation and unsafe. If the black wire is the grounded (neutral) conductor, then it's a possible code violation but safe.
If the black wire is the ungrounded (hot) conductor, then you're switching the grounded (neutral) conductor. This is a code violation, and is not safe. In this situation, the fixture will always be energized. Touching the wrong part could deliver a fatal shock, despite the position of the switch.
If the white wire is the ungrounded (hot) conductor, then the circuit is wired in a "safe" manner. However, it's a possible code violation, depending on what code you follow. And could be confusing for anybody working on the wiring, which could lead to a potentially dangerous situation.
To determine what's going on, you'll have to take some measurements with a multimeter or voltmeter with the power on. Always use caution when working with wiring, especially live wiring.
- Set the meter to measure voltage.
- Touch one probe to the ground wire or terminal, and the other to an exposed portion of the black wire or a terminal where the black wire terminates.
- Note the reading.
- Touch one probe to the ground wire or terminal, and the other to an exposed portion of the white wire or a terminal where the white wire terminates.
- Note the reading.
If you measured 120 volts (or whatever line voltage is) between the black and ground wires, then the black wire is the ungrounded (hot) conductor. If you measured 120 volts (or whatever line voltage is) between the white wire and ground, then the white wire is the ungrounded (hot) conductor.