Last month, a federal judge approved what he called "the ultimate tax shelter" -- a scheme by which, he said, rich investors could avoid income taxes on their earnings completely. But tax advisers aren't cheering the ruling; most are counseling their clients not to put much faith in it.

"It just can't be allowed to stand," said Washington tax lawyer Stanford Ross.

The scheme is a simple one. Two investors set up Danbury Inc., a Nevada holding company, and turned over to it their holdings in various partnerships. The outfit's certificate of incorporation called for it to be based in the Virgin Islands, where its only office is located.

The company claimed that as a Virgin Islands resident, it did not owe taxes to the U.S. Treasury, but that as a foreign corporation -- one incorporated elsewhere -- it owed no taxes to the government of the Islands either. And that, U.S. District Court Judge David V. O'Brien ruled on Jan. 24, is the correct interpretation.

"We are certain that Congress did not intend to create this aperture in the tax laws," he admitted in his opinion in Danbury v. Olive. "But where one occurs, it is the exclusive province of Congress and the federal chief executive to close it." Even though the lawmakers may have thought the statute said something different, he said, "this rule applies despite the most absurd results."

O'Brien was ruling on a bid by the Virgin Islands to collect money it says is due its tax collectors. But O'Brien's decision went further and said that the holding company owed no U.S. tax, either. The federal government was not a party to the case in the district court, but is likely to try to enter the controversy when it moves up to the court of appeals, where it may be heard as soon as April.

The owners of Danbury were taking advantage of an idea that has been kicked around by tax lawyers for more than five years, and they are not alone at taking a flier on the odd interpretation. Hundreds of millions of dollars of investments have been put into holding companies much like Danbury, with owners hoping that the income they generate will prove to be tax-free. The Danbury case just happened to be the first one to get a court decision.

Actually, Danbury held board meetings in the Islands and maintained an office and a bank account there. But O'Brien suggested that a holding company that had as its "office" nothing more than a post office box could take advantage of the same reading of the law.

The possible loophole stems directly from the unique tax status of the Virgin Islands. Since 1922, Congress has applied its entire tax code to residents of the Islands, but provided that the money due would be paid to the territory's treasury rather than to the federal government in Washington. The local legislature has no power to make any changes in the tax laws. So by satisfying the Virgin Islands tax bill, a company -- or an individual -- also fulfills its tax obligation to Uncle Sam.

A business incorporated someplace other than the Virgin Islands, however, owes the Islands government taxes only on the part of its income that can be traced to business done in St. Thomas, St. John and St. Croix. What Danbury insists is that as a foreign corporation, it cannot be taxed on its income because the partnerships that generate that income operate elsewhere, but that as a resident of the Virgin Islands, its only tax liability is to the Islands government.

The U.S. Treasury, not surprisingly, does not read the law this way. In 1980, the Internal Revenue Service issued a ruling that a company in Danbury's situation could call itself a foreign corporation and would have to pay to the Virgin Islands tax on all of its income, no matter where it was generated.

But O'Brien refused to follow the IRS ruling, saying that the Treasury had no backing for its conclusions other than the desire to close an expensive loophole.

Even though Danbury won the litigation hands down, "I don't think there's going to be a stampede down to the Virgin Islands to do this," said Washington tax lawyer James Riedy. "It's such a strange opinion that I think it's likely to be reversed." O'Brien's insistence that legislative history is beside the point in interpreting the code because its meaning is clear may not be followed by the appellate judges. They can reason that if Congress did not mean to free anyone of all tax obligations, then it must not have done so.

Regardless of how the litigation comes out, though, the concept of a device for avoiding taxes altogether is just too good to be true. If Congress did create the massive loophole that O'Brien found, it's a very good bet that the lawmakers will close it fast. Already, in fact, the House of Representatives has tucked into the tax reform package passed in December a clause that makes clear that in the future the law requires companies escaping from U.S. taxes to pay the same amount to the Virgin Islands.

But even the smart investors who set up Danbury-like operations in the past may not reap a bonanza. E. Eliot Rosen, editor of the Tax Analysts publications, suggests that the 1980 Revenue Ruling gave taxpayers enough of a warning that the scheme might not work so that the Senate may make the House provision applicable to every tax year after the ruling was issued.