Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > What is @(#) in source files?

Reply
Thread Tools

What is @(#) in source files?

 
 
Alex
Guest
Posts: n/a
 
      05-18-2005
Hi,

Does anyone know what is @(#) in the beginning of each jdk source file?
How is it used? Is it a javadoc tag?

Example:

/*
* @(#)Object.java
*
*/

Alex


 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      05-18-2005
Alex wrote:
> Does anyone know what is @(#) in the beginning of each jdk source file?
> How is it used? Is it a javadoc tag?


Oh you are a young grasshopper. This is the SCCS marker string intended
for the 'what' program.

SCCS (Source Code Control System) is an a age-old version control
system. In fact, it is the original UNIX version control system (long
ago most people dropped it for the free RCS version control system,
which people later often dropped for the free CVS version control
system, which in turn is about to be dropped by people for the
Subversion version control system ...)

The idea is to have a marker in a file (source or binary) which can
easily be distinguished from other data. The 'what' program simply looks
for text of the form '@(#) ... \0' in all kinds of files, and prints the
text.

If one combines this with SCCS' ability to expand keywords during
checkout, you can get automatically correctly labeled source code. If
you compile the data into a binary, you can trace the binary back to the
source from which it was build.

This works better in C than in Java. If you write something like

char sccsid[] = "@(#)text";

in C it ends up as the correct byte sequence in the binary (the trailing
'\0' is implicit in C strings. but in Java it isn't, and you can't just
insert an own \0 in the string. Well, you can, but Java encodes the \0
not as a 00, but as C0 80 (which is not well formed UTF-8, but common).

.. If you do the equivalent in java

String sccsid = "@(#)text";

you have to find a way to get the \0 into that string. This is left as
an exercise to the reader.

The real question is why Sun still uses the age old SCCS. Well, AFAIK it
is still the base for Sun's Teamware / Forte Code Management Software
version control system. Also AFAIK Teamware is not a big player in the
commercial version control software market.

/Thomas


--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
 
 
 
Betty
Guest
Posts: n/a
 
      05-18-2005

"Thomas Weidenfeller" <> wrote in message
news:d6f149$k36$...
> Alex wrote:
> > Does anyone know what is @(#) in the beginning of each jdk source file?
> > How is it used? Is it a javadoc tag?

>
> Oh you are a young grasshopper. This is the SCCS marker string intended
> for the 'what' program.
>
> SCCS (Source Code Control System) is an a age-old version control
> system. In fact, it is the original UNIX version control system (long
> ago most people dropped it for the free RCS version control system,
> which people later often dropped for the free CVS version control
> system, which in turn is about to be dropped by people for the
> Subversion version control system ...)
>
> The idea is to have a marker in a file (source or binary) which can
> easily be distinguished from other data. The 'what' program simply looks
> for text of the form '@(#) ... \0' in all kinds of files, and prints the
> text.
>
> If one combines this with SCCS' ability to expand keywords during
> checkout, you can get automatically correctly labeled source code. If
> you compile the data into a binary, you can trace the binary back to the
> source from which it was build.
>
> This works better in C than in Java. If you write something like
>
> char sccsid[] = "@(#)text";
>
> in C it ends up as the correct byte sequence in the binary (the trailing
> '\0' is implicit in C strings. but in Java it isn't, and you can't just
> insert an own \0 in the string. Well, you can, but Java encodes the \0
> not as a 00, but as C0 80 (which is not well formed UTF-8, but common).
>
> . If you do the equivalent in java
>
> String sccsid = "@(#)text";


How about
String sccsid = "@(#)textq";
sccsid.charAt(=0;

> you have to find a way to get the \0 into that string. This is left as
> an exercise to the reader.
>
> The real question is why Sun still uses the age old SCCS. Well, AFAIK it
> is still the base for Sun's Teamware / Forte Code Management Software
> version control system. Also AFAIK Teamware is not a big player in the
> commercial version control software market.
>
> /Thomas
>
>
> --
> The comp.lang.java.gui FAQ:
> ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq



 
Reply With Quote
 
Wayne
Guest
Posts: n/a
 
      05-18-2005
Thomas Weidenfeller wrote:
> Alex wrote:
>
>> Does anyone know what is @(#) in the beginning of each jdk source file?
>> How is it used? Is it a javadoc tag?

>
>
> Oh you are a young grasshopper. This is the SCCS marker string intended
> for the 'what' program.
>
> SCCS (Source Code Control System) is an a age-old version control
> system. In fact, it is the original UNIX version control system (long
> ago most people dropped it for the free RCS version control system,
> which people later often dropped for the free CVS version control
> system, which in turn is about to be dropped by people for the
> Subversion version control system ...)
>
> The idea is to have a marker in a file (source or binary) which can
> easily be distinguished from other data. The 'what' program simply looks
> for text of the form '@(#) ... \0' in all kinds of files, and prints the
> text.
>
> If one combines this with SCCS' ability to expand keywords during
> checkout, you can get automatically correctly labeled source code. If
> you compile the data into a binary, you can trace the binary back to the
> source from which it was build.
>
> This works better in C than in Java. If you write something like
>
> char sccsid[] = "@(#)text";
>
> in C it ends up as the correct byte sequence in the binary (the trailing
> '\0' is implicit in C strings. but in Java it isn't, and you can't just
> insert an own \0 in the string. Well, you can, but Java encodes the \0
> not as a 00, but as C0 80 (which is not well formed UTF-8, but common).
>
> . If you do the equivalent in java
>
> String sccsid = "@(#)text";
>
> you have to find a way to get the \0 into that string. This is left as
> an exercise to the reader.
>
> The real question is why Sun still uses the age old SCCS. Well, AFAIK it
> is still the base for Sun's Teamware / Forte Code Management Software
> version control system. Also AFAIK Teamware is not a big player in the
> commercial version control software market.
>
> /Thomas
>
>


You have a good memory! Except you forgot to declare the C string as "static".
This was needed at Bell Labs on SysV to keep SCCS strings in the binaries but
out of the .data section of the COFF a.out. (This used a modified C compiler
that created a .SCCS section on the file that, unlike .data, wouldn't auto-load
into RAM.) When you consider large applications we built in those days were
build of about 2,000 source files, each with SCCS keyword strings of around 20
to 60 bytes in length, and also consider the largest mainframes costing
millions could only have 32 MB of RAM, this made sense.

In Java you can use:

String sccsid = "@(#)text\u0000";

Even if using RCS or CVS with Java, the "what" program can be useful:

String rcsid = "@(#)$Id$\u0000";

and RCS will expand the "$Id$" part when you check your code out.

-Wayne
 
Reply With Quote
 
Dale King
Guest
Posts: n/a
 
      05-19-2005
Betty wrote:
> "Thomas Weidenfeller" <> wrote in message
> news:d6f149$k36$...
>
>>Alex wrote:
>>
>>>Does anyone know what is @(#) in the beginning of each jdk source file?
>>>How is it used? Is it a javadoc tag?

>>
>>Oh you are a young grasshopper. This is the SCCS marker string intended
>>for the 'what' program.
>>
>>SCCS (Source Code Control System) is an a age-old version control
>>system. In fact, it is the original UNIX version control system (long
>>ago most people dropped it for the free RCS version control system,
>>which people later often dropped for the free CVS version control
>>system, which in turn is about to be dropped by people for the
>>Subversion version control system ...)
>>
>>The idea is to have a marker in a file (source or binary) which can
>>easily be distinguished from other data. The 'what' program simply looks
>>for text of the form '@(#) ... \0' in all kinds of files, and prints the
>>text.
>>
>>If one combines this with SCCS' ability to expand keywords during
>>checkout, you can get automatically correctly labeled source code. If
>>you compile the data into a binary, you can trace the binary back to the
>>source from which it was build.
>>
>>This works better in C than in Java. If you write something like
>>
>>char sccsid[] = "@(#)text";
>>
>>in C it ends up as the correct byte sequence in the binary (the trailing
>>'\0' is implicit in C strings. but in Java it isn't, and you can't just
>>insert an own \0 in the string. Well, you can, but Java encodes the \0
>>not as a 00, but as C0 80 (which is not well formed UTF-8, but common).
>>
>>. If you do the equivalent in java
>>
>>String sccsid = "@(#)text";

>
>
> How about
> String sccsid = "@(#)textq";
> sccsid.charAt(=0;


That won't even compile, but wouldn't solve the problem even if it did
as the issue is how to get the string into the class file not how to
create such a string at runtime.
--
Dale King
 
Reply With Quote
 
Dale King
Guest
Posts: n/a
 
      05-19-2005
Wayne wrote:
> Thomas Weidenfeller wrote:
>> This works better in C than in Java. If you write something like
>>
>> char sccsid[] = "@(#)text";
>>
>> in C it ends up as the correct byte sequence in the binary (the
>> trailing '\0' is implicit in C strings. but in Java it isn't, and you
>> can't just insert an own \0 in the string. Well, you can, but Java
>> encodes the \0 not as a 00, but as C0 80 (which is not well formed
>> UTF-8, but common).
>>
>> . If you do the equivalent in java
>>
>> String sccsid = "@(#)text";
>>
>> you have to find a way to get the \0 into that string. This is left as
>> an exercise to the reader.


> In Java you can use:
>
> String sccsid = "@(#)text\u0000";


Nope. That is no different than using \0 and as Thomas said that gets
encoded as C0 80 not as 00.
--
Dale King
 
Reply With Quote
 
Wayne
Guest
Posts: n/a
 
      05-19-2005
Dale King wrote:
> Wayne wrote:
>
>> Thomas Weidenfeller wrote:
>>
>>> This works better in C than in Java. If you write something like
>>>
>>> char sccsid[] = "@(#)text";
>>>
>>> in C it ends up as the correct byte sequence in the binary (the
>>> trailing '\0' is implicit in C strings. but in Java it isn't, and you
>>> can't just insert an own \0 in the string. Well, you can, but Java
>>> encodes the \0 not as a 00, but as C0 80 (which is not well formed
>>> UTF-8, but common).
>>>
>>> . If you do the equivalent in java
>>>
>>> String sccsid = "@(#)text";
>>>
>>> you have to find a way to get the \0 into that string. This is left
>>> as an exercise to the reader.

>
>
>> In Java you can use:
>>
>> String sccsid = "@(#)text\u0000";

>
>
> Nope. That is no different than using \0 and as Thomas said that gets
> encoded as C0 80 not as 00.


Grrr, I think you're right. This is a puzzler! It is easy to get such
a string at runtime, or at compile-time using an array of bytes:
private static byte [] rcsid = { '@', '(', '#', ')', '$', 'I', 'd', '$', \000 };

Of course this destroys the ability of "get" or "co" or
"cvs checkout" to expand the "$Id" keyword(s). But do I give up? No!

Fortunately POSIX defines the "what" program this way:

.... The what utility shall search the given files for all
occurrences of the pattern that get (see get ) substitutes
for the %Z% keyword ( "@(#)" ) and shall write to standard
output what follows until the first occurrence of one of the
following:
" > newline \ NUL
....

So you don't need a NUL at the end, a newline is good enough!
This works:

class Foo {
private static String rcsid = "@(#)$Id$\n";
}

The resulting Foo.class file contains the correct string for "what",
as confirmed by an octal dump. Whew!

-Wayne
 
Reply With Quote
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      05-19-2005
Wayne wrote:
> Dale King wrote:
>> Nope. That is no different than using \0 and as Thomas said that gets
>> encoded as C0 80 not as 00.

>
>
> Grrr, I think you're right. This is a puzzler!


Ok, I will give it away. You can't get a 0 byte in:

http://java.sun.com/docs/books/vmspe....doc.html#7963

Especially:

http://java.sun.com/docs/books/vmspe....doc.html#2874

> Fortunately POSIX defines the "what" program this way:
>
> ... The what utility shall search the given files for all
> occurrences of the pattern that get (see get ) substitutes
> for the %Z% keyword ( "@(#)" ) and shall write to standard
> output what follows until the first occurrence of one of the
> following:
> " > newline \ NUL


Good catch. I think I didn't look at the 'what' man page in the last 15
years.

/Thomas

--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i edit source (like in IE, view..source)? q_q_anonymous@yahoo.co.uk Firefox 4 05-13-2006 11:07 PM
Adding a web application project to source control (Visual Source Safe) ~~~ .NET Ed ~~~ ASP .Net 1 02-26-2005 02:20 PM
Source control and versions of third party source Marcus Leon Java 5 02-03-2005 03:37 PM
Data Recovery SOURCE CODE ( SOURCE CODES of Professional Data Recovery Software ) Author Tarun Tyagi Cisco 0 12-29-2004 05:03 PM
is there a way to "include" source file B.html in source file A.html? Cloud Burst HTML 11 01-09-2004 02:49 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57