January 21, 2021
Hot Topics:

Microsoft Architect Speaks Out on WFCs for Java

  • By Kieron Murphy
  • Send Email »
  • More Articles »

WFC Event Model

Hejlsberg first contrasted the WFC Event model with that of the Java 1.1 AWT. He said the latter uses interfaces in which the event sink must implement the interface, requiring adapter classes, and it is limited to manual multicasting. By contrast, in the WFCs, the event sink just implements a method, requires no adapters, and it offers automatic multicasting, taking care of the "housekeeping" logic.

New to the Java lexicon, the WFCs employ what Microsoft calls "delegates." These are object-oriented function pointers, which rather than simply point to a function entry point, they point to objects and the entry points of methods, according to Hejlsberg.

The following examples are sample code for declaring, creating and invoking WFC delegates, as demonstrated by Hejlsberg.

To declare a single-cast delegate that takes two string arguments and returns an integer:

public delegate int Comparer(String s1, String s2);
To declare a multi-cast delegate that takes an Event object parameter:

public multicast delegate void EventHandler(Event e);
The latter then becomes:
public class EventHandler extends Multicast
        public EventHandler(...) {

        public void invoke(Event e) {
To create a delegate:
public class MyForm extends Form
    Button ok = new Button();

    public void initForm() {
        ok.addOnClick(new EventHandler(this.okClick));

    public void okClick(Object sender, Event e) {
        MessageBox.show("You pressed Ok.");
To invoke a delegate:
public class Button extends Control
    EventHandler click;

    public void addOnClick(EventHandler value) {
        click = (EventHandler)Delegate.combine(click, value);

    protected void onClick(Event e) {
        if (click != null) click.invoke(this, e);
The following illustration demonstrates how delegates work in principle.

Figure 5. Delegates in action (courtesy of Microsoft Corp.).

Events and delegates can have two basic types of relationships, according to Hejlsberg. They can have a many-to-one relationship, in which multiple events can be mapped to the same event handler; or they can play a one-to-many role, in which multicasting enables multiple event sinks. Since delegates are objects, they can use lists, hash-tables and so forth for storage. And by using dynamic event routing, developers can add or remove event handlers at runtime.

Grab Bag of Features

The Microsoft architect also spoke of additional features to be found in the new foundation classes. These include:
  • stateless components, which can modify any property at any time and in any order, as well as provide on-demand resource allocation and auto-recreation as needed
  • automated garbage collection, which eliminates resource leaks or invalid handles and enables developers to manually dispose of components
  • encapsulated native access, which enables access to underlying platform resources and which employs J/Direct or COM to allow access to any API
  • GDI encapsulation, which consists of a graphics class, GDI objects and image classes
  • resources and localization, in which properties can be marked localizable and a ResourceManager class and Locale class are available
  • And miscellaneous "other goodies" such as an ArraySorter and StringSorter.

Key Words in Debate

In response to numerous press accounts in recent days focusing on new "key words" being added to Java in the WFCs, Hejlsberg said that the reports must be referring to the use of "delegate" and "multicast." These features are only "extensions" to Sun Microsystems' version of Java, according to Hejlsberg, which can be "switched off" by any user of the Windows Foundation Classes. (He also stated that two new key words will also make their entrance to Java terminology in the Visual J++ 6.0 compiler: "conditional compilation" and "conditional methods.")

He asserted that everything done with the WFCs is compatible with Microsoft's license with Sun to use Java.

Asked about the timing of today's announcement relevant to Sun's release last week of Version 1.1 of the Java Foundation Classes, Swing 1.0, the WFC architect said this was just a "pure coincidence." He claimed that he deliberately avoided looking at the Sun JFCs, so as not to compromise his own team's design efforts.

A spokesperson for the Java product development group at Microsoft said of the matter that Swing 1.0 is "analogous in functionality to the AFC class library" released last summer. "We then took AFC and tried building significant pieces of software with it and failed. AFC will continue to exist to allow customers to address the limited set of development issues that a diluted, lowest-common-denominator cross-platform set of class libraries can solve," said Jon Roskill, a Visual J++ product manager. "You can not compare JFC/Swing and WFC, they are like apples and oranges. The amount of functionality you get with WFC on Windows versus JFC/Swing is like comparing a Boeing 777 to a 1969 VW Beetle. We are having great success building commercial software in VJ/WFC, the VJ6 tool itself is a great example of this ... significant parts are built using WFC in itself."

Hejlsberg said that reaction from developers who had seen the WFCs demo'ed was "very positive." Roskill added that several tool vendors, including Sybase's Powersoft division and Metrowerks have already announced support for the WFC in their Java tools.

"I am sure others will follow," he said. "Beyond tool licensees we have had significant interest in the general third-party tools community."

Hejlsberg reiterated that the number-one goal for the WFCs is to offer developers the best and most pragmatic solutions to their coding needs. "We're solving problems here for people who want to build real-world applications quickly and run them on Windows."

A spokesperson for Sun, the creator of Java and the recently released Swing 1.0 set of Java Foundation Classes, told developer.com that the company was unfazed by the move by Microsoft. "The WFCs only run on Windows, so I don't see them as a threat to the JFCs at all -- the JFCs are cross-platform and secure," said Lisa Poulson, head of public relations at Sun's JavaSoft business unit. "If developers only want to write to Windows, they have lots of APIs and classes to use. More of the same isn't an issue for us."

Go to developer.com's discussion forums for more talk about WFCs.

Link on This Story:

About the Author

Kieron Murphy is the Editorial Manager of EarthWeb, in New York City.

Page 2 of 2

This article was originally published on March 11, 1998

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date